Skip to content

Commit 03b2a8f

Browse files
committed
chore: some random stuff
1 parent 85119fe commit 03b2a8f

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

lua/Comment/extra.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,25 @@ function E.insert_eol(ctype, cfg)
6868

6969
-- We need RHS of cstr, if we are doing block comments or if RHS exists
7070
-- 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 ''
7272

7373
local ecol
74-
if line:match('^$') then
74+
if U.is_empty(line) then
7575
-- 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
7979
else
8080
-- NOTE:
8181
-- 1. Python is the only language that recommends 2 spaces between the statement and the comment
8282
-- 2. Other than that, I am assuming that the users wants a space b/w the end of line and start of the comment
8383
local space = vim.bo.filetype == 'python' and ' ' or ' '
8484
local ll = line .. space .. lcs .. padding
8585

86-
local erow = srow - 1
8786
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 })
8988
end
89+
9090
U.move_n_insert(srow, ecol)
9191
U.is_fn(cfg.post_hook, ctx)
9292
end

lua/Comment/ft.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ function ft.calculate(ctx)
138138

139139
for lang, tree in pairs(langtree:children()) do
140140
if tree:contains(range) then
141-
-- If the language is in range but commentstring is not found, then fallback to filetype commentstring
142141
return ft.get(lang, ctx.ctype) or default
143142
end
144143
end

0 commit comments

Comments
 (0)