Re: [vim/vim] buffered listener cannot obtain the text of a change (PR #21071)
h_east (Vim Github Repository) <[email protected]>
| Newsgroups | gmane.editors.vim.devel |
|---|---|
| Message-ID | <vim/vim/pull/21071/[email protected]> |
h-east left a comment (vim/vim#21071)
Two things about that snippet.
The change is a replacement of whole lines: lines `lnum` up to but not
including `end` become `text`. There is no column in it, so `character` is 0
on both ends -- `v.col - 1` does not belong there.
An empty `text` means those lines are gone. `join("\n") .. "\n"` turns that
into `"\n"` and leaves a blank line behind, so it has to be an empty string:
```vim
contentChanges = changes->mapnew((_, v) => ({
range: {
start: {line: v.lnum - 1, character: 0},
end: {line: v.end - 1, character: 0},
},
text: v.text->empty() ? '' : v.text->join("\n") .. "\n",
}))
```
You are right that 'eol' does not come into it, and the reason is what you
send in didOpen. Give the server the buffer with a trailing newline:
```vim
getbufline(bnr, 1, '$')->join("\n") .. "\n"
```
Then its copy always ends in a newline, line `end - 1` always exists, and
every change is the two lines above. I have run that through a server that
applies the ranges and compares the result with the buffer: text changed in
place, lines added, lines deleted, multibyte replaced, text appended at the
end, and several changes arriving together from a buffered listener.
So I do not think anything has to change on the Vim side for this.
--
Reply to this email directly or view it on GitHub:
https://github.com/vim/vim/pull/21071#issuecomment-5370525356
You are receiving this because you are subscribed to this thread.
Message ID: <vim/vim/pull/21071/[email protected]>
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_dev/vim/vim/pull/21071/c5370525356%40github.com.