Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some comments and suggestion.. #26

Closed
Shane-XB-Qian opened this issue Feb 19, 2021 · 8 comments
Closed

some comments and suggestion.. #26

Shane-XB-Qian opened this issue Feb 19, 2021 · 8 comments

Comments

@Shane-XB-Qian
Copy link

Hi... looks this is a good enhancement (with your another 'spotdiff.vim') vs native vimdiff
// we can see really sometime can not clearly show what chars were different in a line..
// native vimdiff looks compared by line (due to 'patient' algo?!)
// sometime not clear the isk/diff unit, but just the diff in a line..

though it had advantage also,
if appended a 'o' to 'fo', maybe just like to show the 'o' was the diff, not the whole word 'foo'.

  • so is it possible to offer a command to toggle this 2 compare ways?
  • looks hl a bit inconsistent with native, e.g added '123' into 'foo.123.foo', should hl as 'difftext' or 'diffadd'?
  • like How to prevent the plugin from mapping <leader>g #21, and that ticket probably suggested to offer an option to disable those mappings, anyhow if no want those..

so far just a rough feeling, maybe others...... and sorry if bother...........

@rickhowe
Copy link
Owner

so is it possible to offer a command to toggle this 2 compare ways?

g:DiffUnit can be used to change a diff unit like 'Char' and 'Word1'. You can define a command to toggle between them:

command! CDU if &diff | let &diff = 0 | let g:DiffUnit = (g:DiffUnit == 'Word1') ? 'Char' : 'Word1' | let &diff = 1 | endif

looks hl a bit inconsistent with native, e.g added '123' into 'foo.123.foo', should hl as 'difftext' or 'diffadd'?

When g:DIffUnit = 'Word1' and comparing '123' and 'foo.123.foo', the first 'foo.' and the last '.foo' are highlighted in DiffAdd. Original vim never uses DiffAdd in a changed line, though.

like #21, and that ticket probably suggested to offer an option to disable those mappings, anyhow if no want those..

I just followed a sample plugin described in :h write-plugin for keymap. My plugin does not map the key such as <Leader>g if it has already defined.

@Shane-XB-Qian
Copy link
Author

so is it possible to offer a command to toggle this 2 compare ways?

g:DiffUnit can be used to change a diff unit like 'Char' and 'Word1'. You can define a command to toggle between them:

command! CDU if &diff | let &diff = 0 | let g:DiffUnit = (g:DiffUnit == 'Word1') ? 'Char' : 'Word1' | let &diff = 1 | endif

oh.. good.. but looks that's not exactly like native way, to complex code content, sometime native way had advantage.

When g:DIffUnit = 'Word1' and comparing '123' and 'foo.123.foo', the first 'foo.' and the last '.foo' are highlighted in DiffAdd. Original vim never uses DiffAdd in a changed line, though.

the hl of 'diffadd' by that looks confused with added lines, perhaps better to keep like native 'difftext', IMO.

like #21, and that ticket probably suggested to offer an option to disable those mappings, anyhow if no want those..

I just followed a sample plugin described in :h write-plugin for keymap. My plugin does not map the key such as <Leader>g if it has already defined.

yea, i see, but problem is user perhaps did not map one, meantime he/she Not like to get be mapped by this plugin either.
// he/she may like self-control it..

@Shane-XB-Qian
Copy link
Author

IMO: this plugin had advantage when to compare text style content, and with your another 'spotdiff.vim' plugin, to compare by range by needing had much useful.
though if there was a toggle cmd to enable or issue this feature, but not by default would be better.
mostly due to native way had advantage too, or user perhaps used to it..........

@rickhowe
Copy link
Owner

Please use g:DiffModeSync option and :TDChar command, which are deprecated but still available.
The following is from Readme document of version 8.6:

This plugin will synchronously show/reset the highlights of the exact differences as soon as the diff mode begins/ends since a |g:DiffModeSync| is enabled as a default. And the exact differences will be kept updated while editing.

You can use :SDChar and :RDChar commands to manually show and reset the highlights on all or some of lines. To toggle the highlights, use :TDChar command.

|g:DiffModeSync|, |t:DiffModeSync|
Synchronously show/reset/update with diff mode
0 : disable
1 : enable (default)

:[range]SDChar
Show the highlights of difference units for [range]
:[range]RDChar
Reset the highlights of difference units for [range]
:[range]TDChar
Toggle to show/reset the highlights for [range]

@rickhowe
Copy link
Owner

the hl of 'diffadd' by that looks confused with added lines, perhaps better to keep like native 'difftext', IMO.

If DiffText is used instead of DiffAdd,
01
will be;
02
It looks that 'swift' is changed to 'brown' and 'brown' is changed to 'lazy'. But it is not correct.

yea, i see, but problem is user perhaps did not map one, meantime he/she Not like to get be mapped by this plugin either.

I have no good idea. If necessary, please comment out the line 49 of plugin/diffchar.vim:

48	if !hasmapto(plg, 'n') && empty(maparg(key, 'n'))
49		"execute 'nmap <silent> ' . key . ' ' . plg
50	endif
51	execute 'nnoremap <silent> ' plg . ' ' . cmd . '<CR>'

@Shane-XB-Qian
Copy link
Author

It looks that 'swift' is changed to 'brown' and 'brown' is changed to 'lazy'. But it is not correct.

to me, i think user probably just care those words (if word as unit) were diff, how should i knew which were added which were just changed, meant probably just care/knew 'lazy' --> 'swift brown' at first and 'swift brown' --> 'lazy' at next.
// if really wanted, then probably use another hl as long as not same like 'diffadd', since added lines use 'diffadd' also.

I have no good idea. If necessary, please comment out the line 49 of plugin/diffchar.vim

try something like this:

" Configurable Keymaps
if get(g:, 'diffchar_mapping', 0)
	for [key, plg, cmd] in [
		\['[b', '<Plug>JumpDiffCharPrevStart',
										\':call diffchar#JumpDiffChar(0, 0)'],
		\[']b', '<Plug>JumpDiffCharNextStart',
										\':call diffchar#JumpDiffChar(1, 0)'],
		\['[e', '<Plug>JumpDiffCharPrevEnd',
										\':call diffchar#JumpDiffChar(0, 1)'],
		\[']e', '<Plug>JumpDiffCharNextEnd',
										\':call diffchar#JumpDiffChar(1, 1)'],
		\['<Leader>g', '<Plug>GetDiffCharPair',
										\':call diffchar#CopyDiffCharPair(0)'],
		\['<Leader>p', '<Plug>PutDiffCharPair',
										\':call diffchar#CopyDiffCharPair(1)']]
		if !hasmapto(plg, 'n') && empty(maparg(key, 'n'))
			execute 'nmap <silent> ' . key . ' ' . plg
		endif
		execute 'nnoremap <silent> ' plg . ' ' . cmd . '<CR>'
	endfor
endif

@Shane-XB-Qian
Copy link
Author

Please use g:DiffModeSync option and :TDChar command, which are deprecated but still available.

ideally, yea, combine those 2 and ':TDWord' and 'spotdiff.vim' To:

  • ':{range}DiffChar' and ':{range}DiffWord'
  • default use native compare way, to issue those 2 cmd to use for word/char unit just per needing, when finished, then toggle back native way or close.

// well, just my option, i felt this good for text style content compare, and by this way, would be more useful to be common usage.
// but you or others may disagree, so up to you, it's ok..... :-)

@Shane-XB-Qian
Copy link
Author

i've forgot what i said, but should be out-date anyway.. closing..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants