Thanks for your patience with this!
> So the first list are the lines in the buffer?
Yes, correct.
> > ['const x = ``'] [{'lnum': 1, 'col': 11, 'added': 0, 'end': 2}, {'lnum': 1,
> > 'col': 12, 'added': 0, 'end': 2}]
>
> Here you type the first backtick, and the plugin adds the second
> backtick.
Yup, this looked right to me.
> > ['const x = `', '', '`'] [{'lnum': 1, 'col': 12, 'added': 1, 'end': 2},
> > {'lnum': 2, 'col': 1, 'added': 1, 'end': 2}]
>
> Here you type Enter twice. The first time the existing line is split,
> so you get lnum = 1 and end = 2. The second time a line is inserted, so
> you get lnum = 2 and end = 2. You get two entries with "added" equal to
> one, thus two lines have been added, that is also correct.
The problem (or likely my misunderstanding) is that I get both of
these in the same callback, i.e. they both see the buffer in the state
shown, hence neither "sees" the change in line 3.
To provide this in context (perhaps what I should have done from the start).
What I'm doing in response to these callbacks is gathering the
affected lines, adding them to each of the changes, and passing on the
lots to govim (to save roundtrips).
for l:change in a:changes
if l:change.added < 0
let l:change.type = "deleted"
else
if l:change.lnum != l:change.end
let l:change.type = "changed"
let l:change.lines = getbufline(a:bufnr, l:change.lnum,
l:change.end-1+l:change.added)
elseif l:change.added > 0
let l:change.type = "inserted"
let l:change.lines = getbufline(a:bufnr, l:change.lnum,
l:change.lnum+l:change.added-1)
endif
endif
endfor
Or for the second entry in the change list, do I need to move lnum
"forward" by the number of lines added before?
> Perhaps it's confusing that when a line is inserted, the "lnum" is the
> line above which it is inserted. Imagine doing "O" on a line. Doing
> "o" on the previous line has the same effect, thus you get the same line
> numbers.
I _think_ I have this one sorted ;-) But depending on your answer
above that might also prove to be a wrong assumption!
Thanks again,
Paul
--
--
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 on the web visit
https://groups.google.com/d/msgid/vim_dev/CACoUkn5Bug9oPCeGGH-Ee_V1LiJfo_J0226uhsuOthYbQh9SVA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.