[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/[email protected]>
```
Problem:  A callback added with listener_add() is given the line numbers of
          a change but not the text.  When changes are buffered, two changes
          to the same line do not change the line count and are reported
          together, so getbufline() can only return the result of the second
          one.
Solution: Let listener_add() take a Dictionary of options and add a "text"
          option, which stores the resulting text in each item of the list
          of changes.  The text is copied when the change is recorded, so it
          is not affected by later changes.  Invoke the callback early when
          a lot of text has been recorded, to bound the memory used.
```

related: #19621

The API sketched in that discussion has each change entry carry the text from
before and after the change.  Only the text after the change is included here.
The old lines are already gone by the time a change is recorded, so keeping
them needs a separate hook in ml_delete().  An LSP client does not need them:
a textDocument/didChange notification is built from the range in the old
document and the new text, both of which an entry already has.
You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/21071

-- Commit Summary --

  * buffered listener cannot obtain the text of a change

-- File Changes --

    M runtime/doc/builtin.txt (47)
    M src/change.c (81)
    M src/evalfunc.c (19)
    M src/proto/typval.pro (1)
    M src/structs.h (2)
    M src/testdir/test_listener.vim (147)
    M src/testdir/test_vim9_builtin.vim (1)
    M src/typval.c (12)

-- Patch Links --

https://github.com/vim/vim/pull/21071.patch
https://github.com/vim/vim/pull/21071.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/vim/vim/pull/21071
You are receiving this because you are subscribed to this thread.

Message ID: <vim/vim/pull/[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%40github.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.