Hi Christian, On Tue, May 2, 2023 at 9:43 AM Christian Brabandt <vim-dev-git...@256bit.org> wrote:
> I am still confused by the output, even after reading the help section > several times. So index is the index into the list input and byte is the > start byte from that list[index]? > Yes. > And count is the number of changes performed? > Yes. "count" is the number of items in the list added or removed or modified in the diff hunk. > That is a bit confusing, because if an item was added to the list, like > here: > > " few lines added at the end > :echo diff(['abc'], ['abc', 'def', 'ghi']) > [{'from': {'start': {'idx': 1, 'byte': -1}, 'end': {'idx': -1, 'byte': -1}, > 'count': 0}, > 'to': {'start': {'idx': 1, 'byte': 0}, 'end': {'idx': 2, 'byte': 2}, > 'count': 2}}] > > the count in the to dict means two additional items have been added > (appended) to the list. But then if you take this example: > > " word is removed in the middle of a string > :echo diff(['abc def ghi'], ['abc ghi']) > [{'from': {'start': {'idx': 0, 'byte': 4}, 'end': {'idx': 0, 'byte': 7}, > 'count': 1}, > 'to': {'start': {'idx': 0, 'byte': 4}, 'end': {'idx': 0, 'byte': -1}, > 'count': 1}}] > > Then count does not mean to add or remove a single item to the list, but > apparently that only one single change has been done, e.g. removing from > byte 4 to byte 7. > In this example, there is only one item in the "from" and "to" lists. As this item is modified, the "count" is 1 in both the "from" and "to" dicts. > Also, I guess the help could be a bit more precise, I suppose the -1 > applies only for added items in the from Dict and removed items in the to > Dict > I will update the help text to clarify this. > Each item in the returned List is a Dict containing > information about a diff hunk. Each Dict contains the > following items: > from Dict with {list1} diff hunk information > to Dict with {list2} diff hunk information > The "from" and "to" Dicts contain the following items: > start Dict containing the starting index and byte of the > diff hunk. The "byte" is -1 if text is added > (in the "from" Dict) or removed (in the "to" Dict). > end Dict containing the ending index and byte of the > diff hunk. The "idx" and "byte" are -1 if text is > added (in the "from" Dict) or removed (in the "to" Dict). > count number of items added/removed/modified in this diff > hunk. > > And how would this look like if we have several hunks? Can we have this as > example as well? > Yes. I will add additional examples for multiple diff hunks. > Also I would have thought you would need something like oldstart,oldcount > newstart,newcount which basically is the hunk header from a unified diff. > So perhaps we can just also add the raw diff output per hunk as well? > > > The raw diff output from xdiff contains the line number and count for both the original and new lines. Are you referring to including these in the output? 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 vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/CAAW7x7%3Dgm3SdXRi1oGVVZHKND%2B45SreHEF_q34tTZrkpupxEbw%40mail.gmail.com.