Hi Bram,

On Sun, Apr 30, 2023 at 1:26 PM Bram Moolenaar <[email protected]>
wrote:

>
> > Add support for computing diff between two Lists of strings using a
> > function.
> >
> > When using a LSP plugin, whenever a buffer is modified, the
> > modifications are sent to the language server.
> > To do this, the LSP plugins have implemented computing the diff in
> > Vimscript or in Lua:
> >
> >
> https://github.com/prabirshrestha/vim-lsp/blob/master/autoload/lsp/utils/diff.vim
> > https://github.com/natebosch/vim-lsc/blob/master/autoload/lsc/diff.vim
> >
> https://github.com/neovim/neovim/blob/master/runtime/lua/vim/lsp/sync.lua
> >
> > These computations are expensive as they compare every character and
> > line in a buffer.
> > This new function will help in efficiently computing the diff.
>
> I suppose you made the structure of the return value work for your
> purpose. It's a bit strange though: List of Dict of Dicts. And using a
> special "end" item to indicate added or removed text (the help is not
> clear, but I guess this is only used when a whole item was
> added/removed, not when a word was added/removed).
>

The "end" item contains the end index and the byte offset of the diff hunk.
If the string was not present earlier, then the byte offset cannot be
calculated.  So it will be -1.   When a word is removed, it contains the
position of the end of the word.


>
> To find inserted or removed list items requires checking whether the
> "byte" item indicates the end of the string.
>
> Wouldn't it be easier to use when returning something similar to unified
> diff:
>
- Indicate range of deleted items (like a "-" line)
> - Indicate range of inserted items (like a "+" line)
> - Indicate a modified item (like a "-" line followed by a "+" line)
>

The start and end index values in the returned Dict does contain the
above information (range of deleted or inserted or modified items).


>
> Could be done with a "count" item, which is negative for deleted items,
> positive for inserted items and zero if items were modified.
>
> Does this still fit in with what you need for LSP support?
>
>
> Minor remarks:
>
> +diff({list}, {list} [, {options}])
> + List compute the diff of two List of strings
>
> "List" -> "Lists".
> "of" sounds a bit wrong, using "between" makes the text wrap. How about
> "diff two Lists of strings"?
>
>
I have updated the help text.

Regards,
Yegappan

-- 
-- 
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/CAAW7x7m6iav1XXbi-wVHtG%2B_b6EL3QQ2G2xqeOhPR66AUc%2BW%2Bg%40mail.gmail.com.

Raspunde prin e-mail lui