nvim-treesitter-textobjects icon indicating copy to clipboard operation
nvim-treesitter-textobjects copied to clipboard

fix(shared) better inner parameter selection

Open przepompownia opened this issue 1 year ago • 10 comments

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

przepompownia avatar Oct 15 '24 17:10 przepompownia

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 avatar Oct 15 '24 17:10 przepompownia

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

Fixed and added test cases.

przepompownia avatar Dec 24 '24 22:12 przepompownia

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!

kiyoon avatar Dec 25 '24 05:12 kiyoon

I noticed this PR hasn't progressed in a while. Would you be open to me helping complete it by addressing the requested changes?

PMassicotte avatar Aug 06 '25 11:08 PMassicotte

I noticed this PR hasn't progressed in a while. Would you be open to me helping complete it by addressing the requested changes?

Please feel free to convert this PR to a more convincing version.

przepompownia avatar Aug 06 '25 12:08 przepompownia

I have tested it on my side for a couple of days and have not faced any issues with any *.inner selection modes. I am not too sure on how to add changes to your PR. I will take a look.

PMassicotte avatar Aug 06 '25 13:08 PMassicotte

 $ make docs
NVIM_TS=.test-deps/nvim-treesitter .test-deps/nvim-linux-x86_64/nvim-linux-x86_64/bin/nvim -l scripts/update-readme.lua
E5113: Lua chunk: ...x-x86_64/share/nvim/runtime/lua/vim/treesitter/query.lua:372: No parser for language "apex"
stack traceback:
        [C]: in function 'assert'
        ...x-x86_64/share/nvim/runtime/lua/vim/treesitter/query.lua:372: in function 'fn'
        ...inux-x86_64/share/nvim/runtime/lua/vim/func/_memoize.lua:78: in function 'fn'
        ...inux-x86_64/share/nvim/runtime/lua/vim/func/_memoize.lua:78: in function 'get'
        ./lua/nvim-treesitter-textobjects/shared.lua:424: in function 'fn'
        ./lua/nvim-treesitter-textobjects/shared.lua:42: in function 'available_textobjects'
        scripts/update-readme.lua:38: in main chunk
make: *** [Makefile:124: docs] Error 1

so at the moment I cannot regenerate docs on my local side.

przepompownia avatar Aug 06 '25 15:08 przepompownia

Looks like the apex parser is missing.

 $ make docs
NVIM_TS=.test-deps/nvim-treesitter .test-deps/nvim-linux-x86_64/nvim-linux-x86_64/bin/nvim -l scripts/update-readme.lua
E5113: Lua chunk: ...x-x86_64/share/nvim/runtime/lua/vim/treesitter/query.lua:372: No parser for language "apex"
stack traceback:
        [C]: in function 'assert'
        ...x-x86_64/share/nvim/runtime/lua/vim/treesitter/query.lua:372: in function 'fn'
        ...inux-x86_64/share/nvim/runtime/lua/vim/func/_memoize.lua:78: in function 'fn'
        ...inux-x86_64/share/nvim/runtime/lua/vim/func/_memoize.lua:78: in function 'get'
        ./lua/nvim-treesitter-textobjects/shared.lua:424: in function 'fn'
        ./lua/nvim-treesitter-textobjects/shared.lua:42: in function 'available_textobjects'
        scripts/update-readme.lua:38: in main chunk
make: *** [Makefile:124: docs] Error 1

so at the moment I cannot regenerate docs on my local side.

I think this is because you need to have all parsers installed, which must be the case on CI.

PMassicotte avatar Aug 06 '25 15:08 PMassicotte

Can you rebase(!) on the latest main and check that it still works?

clason avatar Nov 30 '25 10:11 clason

@przepompownia , can you do it?

PMassicotte avatar Nov 30 '25 11:11 PMassicotte

Superseeded by #840

kiyoon avatar Dec 20 '25 15:12 kiyoon