Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions lua/r/run.lua
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ end
---@param type string
M.insert = function(cmd, type)
if vim.g.R_Nvim_status < 7 then return end
cmd = cmd:gsub("\\", "\020")
cmd = cmd:gsub("'", "\018")
cmd = cmd:gsub('"', "\019")
M.send_to_nvimcom("E", "nvimcom:::nvim_insert(" .. cmd .. ", '" .. type .. "')")
Expand All @@ -445,15 +446,11 @@ M.insert_commented = function()
local lines = {}
for line in code:gmatch("[^\n]+") do
local stripped = line:gsub("%s*#.*", "")
if stripped:match("%S") then
table.insert(lines, stripped)
end
if stripped:match("%S") then table.insert(lines, stripped) end
end
code = table.concat(lines, " ")
-- Move cursor to end of chain
if end_row then
vim.api.nvim_win_set_cursor(0, { end_row, 0 })
end
if end_row then vim.api.nvim_win_set_cursor(0, { end_row, 0 }) end
else
-- Fallback to single line
code = vim.api.nvim_get_current_line():gsub("%s*#.*", "")
Expand Down
7 changes: 7 additions & 0 deletions nvimcom/src/nvimcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,13 @@ static char *unscape_str(const char *a) {
b[j] = '"';
j++;
i += 6;
} else if (a[i + 5] == '4') {
b[j] = '\\';
j++;
i += 6;
} else {
// unknown \u001X: skip to avoid infinite loop
i += 6;
}
} else {
b[j] = a[i];
Expand Down