diff --git a/source/source.go b/source/source.go index c83257fe..3f25fb17 100644 --- a/source/source.go +++ b/source/source.go @@ -196,7 +196,7 @@ func (s *Searcher) NextLines(fname string, line int) (lines []int, err error) { 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()) deferEndLine = endpos.Line return false diff --git a/source/source_test.go b/source/source_test.go index 721c6c83..5d546c4b 100644 --- a/source/source_test.go +++ b/source/source_test.go @@ -41,6 +41,7 @@ func TestNextLines(t *testing.T) { {30, []int{32}}, {62, []int{63}}, {67, []int{71}}, + {68, []int{69}}, } for i, c := range cases { lines, err := v.NextLines(tf, c.line)