@@ -68,25 +68,25 @@ function E.insert_eol(ctype, cfg)
68
68
69
69
-- We need RHS of cstr, if we are doing block comments or if RHS exists
70
70
-- because even in line comment RHS do exists for some filetypes like jsx_element, ocaml
71
- local if_rcs = ( ctype == U . ctype . block or rcs ) and padding .. rcs or ' '
71
+ local if_rcs = rcs and padding .. rcs or ' '
72
72
73
73
local ecol
74
- if line : match ( ' ^$ ' ) then
74
+ if U . is_empty ( line ) then
75
75
-- If line is empty, start comment at the correct indentation level
76
- A .nvim_buf_set_lines (0 , srow - 1 , srow , false , { lcs .. padding .. if_rcs })
77
- vim . cmd (' normal! ==' )
78
- ecol = A .nvim_get_current_line (): len () - if_rcs : len () - 1
76
+ A .nvim_buf_set_lines (0 , srow - 1 , srow , false , { lcs .. padding .. if_rcs })
77
+ A . nvim_command (' normal! ==' )
78
+ ecol = # A .nvim_get_current_line () - # if_rcs - 1
79
79
else
80
80
-- NOTE:
81
81
-- 1. Python is the only language that recommends 2 spaces between the statement and the comment
82
82
-- 2. Other than that, I am assuming that the users wants a space b/w the end of line and start of the comment
83
83
local space = vim .bo .filetype == ' python' and ' ' or ' '
84
84
local ll = line .. space .. lcs .. padding
85
85
86
- local erow = srow - 1
87
86
ecol = # ll - 1
88
- A .nvim_buf_set_lines (0 , erow , srow , false , { ll .. if_rcs })
87
+ A .nvim_buf_set_lines (0 , srow - 1 , srow , false , { ll .. if_rcs })
89
88
end
89
+
90
90
U .move_n_insert (srow , ecol )
91
91
U .is_fn (cfg .post_hook , ctx )
92
92
end
0 commit comments