nvim-treesitter / nvim-treesitter-textobjects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Swap function skips a line

Feel-ix-343 opened this issue · comments

Describe the bug
A clear and concise description of what the bug is.

While swapping by @parameters.inner does work as intended in a lua file, swapping by a custom query, such as @list_items (see below), in a markdown file seems to skip over an item when swapping. This behavior is shown in the video below.

To Reproduce
Steps to reproduce the behavior:

  1. Create the query ;;extends\n(list_item) @list_item in a custom /after/queries/markdown/textobjects.scm file
  2. Try to do a textobject swap in a markdown file

Expected behavior
A clear and concise description of what you expected to happen.

The list items should swap consecutively, but the swap seems to skip over an item.

Output of :checkhealth nvim-treesitter

==============================================================================
nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~

  • OK tree-sitter found 0.20.8 (parser generator, only needed for :TSInstallFromGrammar)
  • OK node found v19.9.0 (only needed for :TSInstallFromGrammar)
  • OK git executable found.
  • OK cc executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
    Version: cc (GCC) 12.2.1 20230201
  • OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
machine = "x86_64",
release = "6.2.12-arch1-1",
sysname = "Linux",
version = "#1 SMP PREEMPT_DYNAMIC Thu, 20 Apr 2023 16:11:55 +0000"
} ~

Parser/Features H L F I J

  • lua ✓ ✓ ✓ ✓ ✓
  • markdown ✓ . ✓ . ✓
  • markdown_inline ✓ . . . ✓
  • query ✓ ✓ ✓ ✓ ✓
  • rust ✓ ✓ ✓ ✓ ✓
  • tsx ✓ ✓ ✓ ✓ ✓
  • typescript ✓ ✓ ✓ ✓ ✓
  • vimdoc ✓ . . . ✓
  • yuck ✓ ✓ ✓ ✓ ✓

Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang} ~

Output of nvim --version

NVIM v0.9.0-dev-1147+ge389b1890
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-10 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -fno-common -Wno-unused-result -Wimplicit-fallthrough -fdiagnostics-color=always -fstack-protector-strong -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/home/runner/work/neovim/neovim/.deps/usr/include/luajit-2.1 -I/usr/include -I/home/runner/work/neovim/neovim/.deps/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include -I/home/runner/work/neovim/neovim/build/cmake.config -I/home/runner/work/neovim/neovim/src -I/usr/include -I/home/runner/work/neovim/neovim/.deps/usr/include -I/home/runner/work/neovim/neovim/.deps/usr/include -I/home/runner/work/neovim/neovim/.deps/usr/include -I/home/runner/work/neovim/neovim/.deps/usr/include -I/home/runner/work/neovim/neovim/.deps/usr/include -I/home/runner/work/neovim/neovim/.deps/usr/include

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info

Additional context
Add any other context about the problem here.

Running the query from tsplayground

2023-04-23_20-23

Showing the scm file with the lua config

2023-04-23_20-28

A video of expected behavior and the bug

2023-04-23.20-34-23.mp4

so lonely...

Sorry for the delay and thanks for reporting. I think I found what the problem is. Hope the PR doesn't break anything else.

Wow. Amazing.

(I thought I was doing something wrong! Maybe not?)

If you can test the PR with many different swapping scenarios, it will be helpful!