@@ -13,22 +13,24 @@ local function get_buf_text(bufnr)
13
13
local line_number = vim .api .nvim_win_get_cursor (0 )[1 ]
14
14
local column = vim .api .nvim_win_get_cursor (0 )[2 ]
15
15
local line = lines [line_number ]
16
- local start_col = column
17
- while start_col > 1 do
18
- local char = line :sub (start_col , start_col )
19
- if char :match (' [%w_\\ -]' ) == nil then
20
- start_col = start_col + 1
21
- break
16
+ if line ~= nil then
17
+ local start_col = column
18
+ while start_col > 1 do
19
+ local char = line :sub (start_col , start_col )
20
+ if char :match (' [%w_\\ -]' ) == nil then
21
+ start_col = start_col + 1
22
+ break
23
+ end
24
+ start_col = start_col - 1
22
25
end
23
- start_col = start_col - 1
24
- end
25
- local end_col = column
26
- while end_col < # line do
27
- local char = line : sub ( end_col + 1 , end_col + 1 )
28
- if char : match ( ' [%w_ \\ -] ' ) == nil then break end
29
- end_col = end_col + 1
26
+ local end_col = column
27
+ while end_col < # line do
28
+ local char = line : sub ( end_col + 1 , end_col + 1 )
29
+ if char : match ( ' [%w_ \\ -] ' ) == nil then break end
30
+ end_col = end_col + 1
31
+ end
32
+ lines [ line_number ] = line : sub ( 1 , start_col ) .. ' ' .. line : sub ( end_col + 1 )
30
33
end
31
- lines [line_number ] = line :sub (1 , start_col ) .. ' ' .. line :sub (end_col + 1 )
32
34
33
35
return table.concat (lines , ' \n ' )
34
36
end
0 commit comments