nvim-treesitter / nvim-treesitter-refactor

Refactor module for nvim-treesitter
Apache License 2.0
408 stars 25 forks source link

Smart rename duplicates letters (related to a change of lsp apply_edits?) #11

Closed theHamsta closed 3 years ago

theHamsta commented 3 years ago

Describe the bug Letters gets duplicated on smart rename.

To Reproduce

Use the smart rename feature on the third occurrence of x (the first in the second line). Rename it to xyz

Before text

data = [int(x) for x in "193467258"]
data_p1, x, p1 = play(data), 1, []
for i in range(1, len(data)):
    x = data_p1[x]
    p1.append(x)

After text

data = [int(x) for x in "193467258"]
data_p1, xyzyz, p1 = play(data), 1, []
for i in range(1, len(data)):
    xyzyz = data_p1[xyzyz]
    p1.append(xyzyz)

Expected behavior Identifier is renamed to the exact string I chose: xyz instead of xyzyz.

Output of :checkhealth nvim_treesitter

❯ nvim --version NVIM v0.5.0-dev+1048-g69103ff0c Build type: Release LuaJIT 2.1.0-beta3 Compilation: /usr/lib/ccache/clang-12 -fcolor-diagnostics -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -s td=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=a lways -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/stephan /projects/neovim/release/config -I/home/stephan/projects/neovim/src -I/home/stephan/projects/neovim/.deps/usr/include -I/usr/include/lua5.1 -I/usr/local/include -I/usr/include -I/home/stephan/projects/neovim/release/src/nvim/auto -I/home/stephan/projects/neovim/release/include Compiled by stephan@stephan-Z87-DS3H Features: +acl +iconv +tui See ":help feature-compile" system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/local/share/nvim" Run :checkhealth for more info

Output of nvim --version

❯ nvim --version
NVIM v0.5.0-dev+1048-g69103ff0c
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: /usr/lib/ccache/clang-12 -fcolor-diagnostics -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -s
td=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=a
lways -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/stephan
/projects/neovim/release/config -I/home/stephan/projects/neovim/src -I/home/stephan/projects/neovim/.deps/usr/include -I/usr/include/lua5.1
 -I/usr/local/include -I/usr/include -I/home/stephan/projects/neovim/release/src/nvim/auto -I/home/stephan/projects/neovim/release/include
Compiled by stephan@stephan-Z87-DS3H

Features: +acl +iconv +tui
See ":help feature-compile"

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

Run :checkhealth for more info

Additional context N/A

theHamsta commented 3 years ago

I suspect the reason for this is the crazy query duplication. Each reference is found multiple times and then replaced multiple times @steelsojka

It's is easy to fix but I don't know in which repo. It's wrong in so many ways: