@@ -92,24 +92,18 @@ function! s:TokeniseLine(line_num)
9292 while 1
9393 " We perform searches within the buffer (and move the cusor)
9494 " for better performance than looping char by char in a line.
95- let token = searchpos (' [()[\]{};"]' , ' bW' , a: line_num )
95+ let token_pos = searchpos (' [()[\]{};"]' , ' bW' , a: line_num )
9696
9797 " No more matches, exit loop.
98- if token == [0 , 0 ] | break | endif
98+ if token_pos == [0 , 0 ] | break | endif
9999
100- let t_idx = token [1 ] - 1
100+ let t_idx = token_pos [1 ] - 1
101101
102102 " Escaped character, ignore.
103103 if s: IsEscaped (ln , t_idx) | continue | endif
104104
105- let t_char = ln [t_idx]
106- if t_char == # ' ;'
107- " Comment found, reset the token list for this line.
108- let tokens = []
109- elseif t_char = ~# ' [()\[\]{}"]'
110- " Add token to the list.
111- call add (tokens, [t_char, token])
112- endif
105+ " Add token to the list.
106+ call add (tokens, [ln [t_idx], token_pos])
113107 endwhile
114108
115109 return tokens
@@ -151,6 +145,9 @@ function! s:InsideForm(lnum)
151145 endif
152146 elseif in_string
153147 " In string: ignore other tokens.
148+ elseif tk[0 ] == # ' ;'
149+ " Comment: break loop.
150+ break
154151 elseif ! empty (tokens) && get (s: pairs , tk[0 ], ' ' ) == # tokens[-1 ][0 ]
155152 " Matching pair: drop the last item in tokens.
156153 call remove (tokens, -1 )
0 commit comments