neovim / neovim

Vim-fork focused on extensibility and usability
https://neovim.io
Other
83.16k stars 5.69k forks source link

treesitter: undoing confirmed substitution does not trigger reparse #30184

Open g-cassie opened 2 months ago

g-cassie commented 2 months ago

Problem

Given the following lua file:

local foo = {
  attribute1 = false,
  attribute2 = false,
}

If you do %s/attribute/attr/gc, confirm both changes and then press undo, the tree sitter parsing gets out of sync.

Screenshot 2024-08-29 at 10 21 44 AM

cc @gpanders and @clason

Steps to reproduce

  1. nvim --clean

  2. :hi @boolean guifg=red

  3. Paste in these file contents:

    local foo = {
    attribute1 = false,
    attribute2 = false,
    }
  4. :%s/attribute/attr/gc

  5. y y

  6. u

Expected behavior

false should be formatted in red and attribute2 formatted in grey.

Neovim version (nvim -v)

0.10.1

Vim (not Nvim) behaves the same?

n/a

Operating system/version

macos 14.6

Terminal name/version

ghostty fcb8b040

$TERM environment variable

xterm-ghostty

Installation

homebrew

clason commented 2 months ago

Note that the confirm is necessary to trigger this, as is accepting both substitutions (one n in either position breaks the reproducer, as does selecting all).

gpanders commented 2 months ago

CC @famiu as our command preview expert.

famiu commented 2 months ago

CC @famiu as our command preview expert.

I did make some changes to how TS highlights are done during the inccommand refactor, I'm assuming that may be the reason behind this behavior. I will look into this once I'm done with work on options.