Handle 'next'ing in deferred funcs

This commit is contained in:
Derek Parker
2015-05-09 12:53:25 -05:00
parent e4a20d596a
commit 72eebe5c4b
2 changed files with 2 additions and 1 deletions

View File

@ -196,7 +196,7 @@ func (s *Searcher) NextLines(fname string, line int) (lines []int, err error) {
return true return true
} }
if dn, ok := n.(*ast.DeferStmt); ok { if dn, ok := n.(*ast.DeferStmt); ok && line < pos.Line {
endpos := s.fileset.Position(dn.End()) endpos := s.fileset.Position(dn.End())
deferEndLine = endpos.Line deferEndLine = endpos.Line
return false return false

View File

@ -41,6 +41,7 @@ func TestNextLines(t *testing.T) {
{30, []int{32}}, {30, []int{32}},
{62, []int{63}}, {62, []int{63}},
{67, []int{71}}, {67, []int{71}},
{68, []int{69}},
} }
for i, c := range cases { for i, c := range cases {
lines, err := v.NextLines(tf, c.line) lines, err := v.NextLines(tf, c.line)