Skip to content
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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

przepompownia
Copy link
Contributor

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 #700

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
@przepompownia przepompownia marked this pull request as draft October 15, 2024 17:04
@przepompownia
Copy link
Contributor Author

przepompownia commented Oct 15, 2024

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 function.outer selection (when the cursor is in the function body).

@przepompownia przepompownia marked this pull request as ready for review October 15, 2024 18:37
@przepompownia przepompownia marked this pull request as draft December 24, 2024 21:14
@przepompownia
Copy link
Contributor Author

Currently the change breaks function.outer selection (when the cursor is in the function body).

Fixed and added test cases.

@przepompownia przepompownia marked this pull request as ready for review December 24, 2024 22:55
@@ -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" } })
Copy link
Collaborator

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

Copy link
Contributor Author

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;).

@kiyoon
Copy link
Collaborator

kiyoon commented Dec 25, 2024

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 master branch, there is no such issue.

I'd like to accept this PR but I didn't follow much on main and the function you modified doesn't exist in master..

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)
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants