Skip to content
Open
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
29 changes: 26 additions & 3 deletions lua/r/send.lua
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,16 @@ local M = {}
---@param should_dedent boolean Whether to dedent the code
---@param m string|nil Movement mode ("move" or nil)
---@return boolean Whether the command was sent successfully
local function send_chunk_line(chunk, line, lnum, lang, stop_fn, wrap_fn, should_dedent, m)
local function send_chunk_line(
chunk,
line,
lnum,
lang,
stop_fn,
wrap_fn,
should_dedent,
m
)
local lines
lines, lnum = get_ts_code_to_send(chunk, line, lnum, lang, stop_fn)
local code = table.concat(lines, "\n")
Expand Down Expand Up @@ -507,8 +516,22 @@ M.motion_wrapper = function()

motion = char

-- If first char is a digit, keep reading digits
while char:match("%d") do
-- If first char is a non-zero digit, keep reading digits
while char:match("[1-9]") do
ok, char = pcall(vim.fn.getcharstr)
if not ok or char == "\27" then return end
motion = motion .. char
end
Comment on lines +520 to +524
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
while char:match("[1-9]") do
ok, char = pcall(vim.fn.getcharstr)
if not ok or char == "\27" then return end
motion = motion .. char
end
if char:match("[1-9]") then
repeat
ok, char = pcall(vim.fn.getcharstr)
if not ok or char == "\27" then
return
end
motion = motion .. char
until not char:match("%d")
end

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not had time to test it, so check before :)


-- If part of two-character motion is typed (in/around), keep reading
if
char == "i"
or char == "a"
or char == "f"
or char == "F"
or char == "t"
or char == "T"
then
ok, char = pcall(vim.fn.getcharstr)
if not ok or char == "\27" then return end
motion = motion .. char
Expand Down
Loading