Skip to content

Commit add13c4

Browse files
committed
fix: wrap element should ignore comments
1 parent 7a988f1 commit add13c4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lua/nvim-paredit/api/form.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ function M.wrap_element(buf, element, prefix, suffix)
1414
end
1515

1616
function M.wrap_element_under_cursor(prefix, suffix)
17-
if langs.is_whitespace_under_cursor() then
18-
return
19-
end
20-
2117
local buf = vim.api.nvim_get_current_buf()
2218
local current_element = ts.get_node_at_cursor()
19+
local lang = langs.get_language_api()
20+
2321
if not current_element then
2422
return
2523
end
24+
if lang.node_is_comment(current_element) then
25+
return
26+
end
27+
if langs.is_whitespace_under_cursor() then
28+
return
29+
end
2630

2731
M.wrap_element(buf, current_element, prefix, suffix)
2832

0 commit comments

Comments
 (0)