Describe the bug
smart_rename does not work correctly when replacing the same variable multiple times in the same row, iff the desired variable name is of different length than the original variable name.
To Reproduce
Consider this code:
template <class Functor>
auto inspect(Functor& f, value& ec) {
return f(ec.a, ec.b);
}
Use smart_rename to rename ec to x.
This is the result:
template <class Functor>
auto inspect(Functor& f, value& x) {
return f(x.a, exb);
}
Expected behavior
template <class Functor>
auto inspect(Functor& f, value& x) {
return f(x.a, x.b);
}
Output of :checkhealth nvim_treesitter
git executable found.cc executable found.highlights.scm found.locals.scm query found for htmltextobjects.scm query found for htmlhighlights.scm found.locals.scm found.textobjects.scm query found for typescripthighlights.scm query found for markdownlocals.scm query found for markdowntextobjects.scm query found for markdownhighlights.scm found.locals.scm query found for regextextobjects.scm query found for regexhighlights.scm found.locals.scm found.textobjects.scm found.highlights.scm query found for nixlocals.scm query found for nixtextobjects.scm query found for nixhighlights.scm query found for swiftlocals.scm query found for swifttextobjects.scm query found for swifthighlights.scm found.locals.scm found.textobjects.scm query found for javahighlights.scm found.locals.scm found.textobjects.scm found.highlights.scm query found for yamllocals.scm query found for yamltextobjects.scm query found for yamlhighlights.scm query found for elmlocals.scm query found for elmtextobjects.scm query found for elmhighlights.scm query found for vuelocals.scm query found for vuetextobjects.scm query found for vuehighlights.scm found.locals.scm found.textobjects.scm found.highlights.scm query found for tomllocals.scm query found for tomltextobjects.scm query found for tomlhighlights.scm found.locals.scm found.textobjects.scm query found for luahighlights.scm found.locals.scm found.textobjects.scm query found for rubyhighlights.scm query found for ocamllocals.scm query found for ocamltextobjects.scm query found for ocamlhighlights.scm found.locals.scm found.textobjects.scm found.highlights.scm query found for scalalocals.scm query found for scalatextobjects.scm query found for scalahighlights.scm query found for haskelllocals.scm query found for haskelltextobjects.scm query found for haskellhighlights.scm found.locals.scm found.textobjects.scm found.highlights.scm found.locals.scm query found for jsontextobjects.scm query found for jsonhighlights.scm query found for jsdoclocals.scm query found for jsdoctextobjects.scm query found for jsdochighlights.scm found.locals.scm found.textobjects.scm query found for javascripthighlights.scm found.locals.scm query found for csstextobjects.scm query found for csshighlights.scm query found for julialocals.scm query found for juliatextobjects.scm query found for juliahighlights.scm query found for phplocals.scm query found for phptextobjects.scm query found for phphighlights.scm query found for c_sharplocals.scm query found for c_sharptextobjects.scm query found for c_sharphighlights.scm found.locals.scm found.textobjects.scm query found for bashhighlights.scm found.locals.scm found.textobjects.scm query found for tsx
Output of nvim --version
โฏ nvim --version
NVIM v0.5.0-nightly-217-g950ca6abc
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20200720-14610-1xe0vle/build/config -I/tmp/neovim-20200720-14610-1xe0vle/src -I/usr/local/include -I/tmp/neovim-20200720-14610-1xe0vle/deps-build/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.16.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20200720-14610-1xe0vle/build/src/nvim/auto -I/tmp/neovim-20200720-14610-1xe0vle/build/include
Compiled by dominiklohmann@amethyst
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-950ca6a/share/nvim"
Run :checkhealth for more info
Hi ! thanks for reporting that ! That's actually a bug ! I think I know how this should be fixed (no time now though) !
@steelsojka didn't you have a similar problem once ?
@steelsojka has already some experience with lsp applyTextEdits
Ok, I think I already implemented it @steelsojka
Could you please test #207 ? @dominiklohmann I will have a look on my PR tomorrow. I just coded in really fast and need to check it again.
Sorry, there's still a bug in the fix.
Should be ok now.
I can confirm your PR fixes the issue for me.
Most helpful comment
I can confirm your PR fixes the issue for me.