-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(shared) better inner parameter selection #702
base: main
Are you sure you want to change the base?
Conversation
The logic of including a point in a range needs `-1` end_col offset only if the point is from the cursor position but not from the end of another range. Fixes nvim-treesitter#700
Examples to cover by test: vim.print(1, tonumber('1')) -- on `tonumber`
vim.print({1, '2'}, 3) -- on closing brace
vim.print({1, '2'}) -- on closing brace Currently the change breaks |
Fixed and added test cases. |
@@ -25,6 +25,10 @@ describe("command equality Python:", function() | |||
run:compare_cmds("aligned_indent.py", { row = 1, col = 0, cmds = { "dfn", "d;" } }) | |||
-- select using move | |||
run:compare_cmds("aligned_indent.py", { row = 1, col = 0, cmds = { "d]a", "v]ad", "c]a" } }) | |||
run:compare_cmds("selection_mode.py", { row = 2, col = 4, cmds = { "dam", "dVam", "vamd", "Vamd" } }) | |||
run:compare_cmds("selection_mode.py", { row = 2, col = 4, cmds = { "dam", "dVam", "vamd", "Vamd", "dG" } }) | |||
run:compare_cmds("selection_mode.py", { row = 3, col = 8, cmds = { "kdG", "dam", "dVam", "vamd", "Vamd" } }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dG
, kdG
motions break when the reference code changes slightly. Maybe better if you do something like d]M
which is more meaningful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My intention was comparing the plugin action with something with something independent, but still reliable. IIRC the test compares results and expect only equation or only difference. In the former case I got passed test when all keystrokes gave the same bad result. While the test is defined as now, let allow to compare with something reliable (line 25 alraedy contains d;
).
I don't use neovim nightly so I could only find time now to test it.. Thanks for reporting it. It's definitely odd and in I'd like to accept this PR but I didn't follow much on Can you investigate a little why this is an issue on main and not master? Thank you! |
---@return boolean | ||
local function is_in_range(range, row, col) | ||
local function is_in_range(range, row, col, end_col_offset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a brief comment on why the end_col_offset is needed (in what situation,) and a link to the issue.
The logic of including a point in a range needs
-1
end_col offsetonly if the point is from the cursor position
but not from the end of another range.
Fixes #700