Repository: neovim
Issue: on_changedtick not called for op_reindent
Labels: bug

<!-- Before reporting: search existing issues and check the FAQ. -->

- `nvim --version`:
```
NVIM v0.5.0-dev+1036-gf9b311054
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: /usr/bin/cc -D_FORTIFY_SOURCE=2 -march=native -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -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/home/jb/.cache/yay/neovim-git/src/build/config -I/home/jb/.cache/yay/neovim-git/src/neovim-git/src -I/usr/include -I/home/jb/.cache/yay/neovim-git/src/build/src/nvim/auto -I/home/jb/.cache/yay/neovim-git/src/build/include
Compiled by jb
```

### Steps to reproduce

Using the following files `changedtick.lua`:
```lua
-- On changedtick
Ticks = 0
function attach_onchangedtick()
  vim.api.nvim_buf_attach(0, false, {
    on_changedtick = function()
      Ticks = Ticks + 1
    end,
  })
end

vim.cmd 'autocmd BufNew,BufRead * lua attach_onchangedtick()'
vim.cmd 'command! Ticks lua print(Ticks)'

-- Indent
math.randomseed(42)

function get_random_indent(lnum)
    print('get_random_indent, changedtick =', vim.b.changedtick, '=', vim.api.nvim_buf_get_changedtick(0))
    local n = math.random(5)
    local width = 4
    local indent = width * n
    return indent
end

local indentexpr = 'v:lua.get_random_indent(v:lnum)'
vim.o.indentexpr = indentexpr
vim.bo.indentexpr = indentexpr
```
and `testfile.txt`:
```
First line
Second line
Third line
Line 4
Last line
```
run:
```
nvim -u changedtick.lua --noplugin testfile.txt
```
and then do `gg=G`. 

### Actual behaviour

The `on_changedtick` callback should be called for each line change.

### Expected behaviour

`Ticks` stays 0. It is only incremented after I undo the changes. 

Actually, when I was testing this in https://github.com/nvim-treesitter/nvim-treesitter/pull/837#issuecomment-757044164 it _was_ triggered, but only once at the end of the operation. When testing this now for some reason I don't even get a call after the whole operation, so I am a bit confused.

### Background

This is an issue encountered when working on indent in nvim-treesitter. I described it in https://github.com/nvim-treesitter/nvim-treesitter/pull/837#issuecomment-757044164. The main issue is that the plugin maintains per-buffer cache that needs to be updated on any buffer change ([like this](https://github.com/nvim-treesitter/nvim-treesitter/blob/master/lua/nvim-treesitter/ts_utils.lua#L206)). `on_changedtick` was used for this purpose, but it does not get called when running an indent operation on multiple lines and treesitter updates the tree on each buffer modification and so the cache maintained in the plugin gets out of sync.

I am not really sure "what calls treesitter" and makes it be reevaluated on any line change. As for `on_changedtick`, I found that `op_reindent` in `ops.c` should call this only once [at the end](https://github.com/neovim/neovim/blob/master/src/nvim/ops.c#L673-L675). I was able to make `changedtick` updated on each line as described in https://github.com/nvim-treesitter/nvim-treesitter/pull/837#issuecomment-758286023, but `on_changedtick` still was not called.