mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
fix(diff): set default diff flags properly (#35450)
This commit is contained in:
@@ -87,10 +87,10 @@ static bool diff_need_update = false; // ex_diffupdate needs to be called
|
|||||||
#define DIFF_FOLLOWWRAP 0x800 // follow the wrap option
|
#define DIFF_FOLLOWWRAP 0x800 // follow the wrap option
|
||||||
#define DIFF_LINEMATCH 0x1000 // match most similar lines within diff
|
#define DIFF_LINEMATCH 0x1000 // match most similar lines within diff
|
||||||
#define ALL_WHITE_DIFF (DIFF_IWHITE | DIFF_IWHITEALL | DIFF_IWHITEEOL)
|
#define ALL_WHITE_DIFF (DIFF_IWHITE | DIFF_IWHITEALL | DIFF_IWHITEEOL)
|
||||||
static int diff_flags = DIFF_INTERNAL | DIFF_FILLER | DIFF_CLOSE_OFF;
|
static int diff_flags = DIFF_INTERNAL | DIFF_FILLER | DIFF_CLOSE_OFF | DIFF_LINEMATCH;
|
||||||
|
|
||||||
static int diff_algorithm = 0;
|
static int diff_algorithm = 0;
|
||||||
static int linematch_lines = 0;
|
static int linematch_lines = 40;
|
||||||
|
|
||||||
#define LBUFLEN 50 // length of line in diff file
|
#define LBUFLEN 50 // length of line in diff file
|
||||||
|
|
||||||
|
@@ -814,6 +814,42 @@ describe('startup', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("default 'diffopt' is applied with -d", function()
|
||||||
|
clear({
|
||||||
|
args = {
|
||||||
|
'-d',
|
||||||
|
'test/functional/fixtures/diff/startup_old.txt',
|
||||||
|
'test/functional/fixtures/diff/startup_new.txt',
|
||||||
|
'--cmd',
|
||||||
|
'set laststatus=0',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
local screen = Screen.new(80, 24)
|
||||||
|
screen:expect([[
|
||||||
|
{7:+ }{13:^+-- 15 lines: package main············}│{7:+ }{13:+-- 15 lines: package main···········}|
|
||||||
|
{7: } │{7: } |
|
||||||
|
{7: }func printCharacters(str string) strin│{7: }func printCharacters(str string) stri|
|
||||||
|
{7: } return str │{7: } return str |
|
||||||
|
{7: }} │{7: }} |
|
||||||
|
{7: } │{7: } |
|
||||||
|
{7: }func main() { │{7: }func main() { |
|
||||||
|
{7: }{23:--------------------------------------}│{7: }{22: hello := "Hello, World!" }|
|
||||||
|
{7: }{23:--------------------------------------}│{7: }{22: }|
|
||||||
|
{7: }{4: fmt.Print}{27:Ln}{4:(compressString("aa}│{7: }{4: fmt.Print(compressString("aaa}|
|
||||||
|
{7: }{4: fmt.Print}{27:Ln}{4:(compressString("go}│{7: }{4: fmt.Print(compressString("gol}|
|
||||||
|
{7: }{4: fmt.Print}{27:Ln}{4:(removeDuplicate("a}│{7: }{4: fmt.Print(removeDuplicate("aa}|
|
||||||
|
{7: }{4: fmt.Print}{27:Ln}{4:(reverseAndDouble("}│{7: }{4: fmt.Print(reverseAndDouble("a}|
|
||||||
|
{7: }{4: fmt.Print}{27:Ln}{4:(printCharacters("g}│{7: }{4: fmt.Print(printCharacters("go}|
|
||||||
|
{7: }{23:--------------------------------------}│{7: }{22: }|
|
||||||
|
{7: }{23:--------------------------------------}│{7: }{22: fmt.Println(hello) }|
|
||||||
|
{7: }} │{7: }} |
|
||||||
|
{1:~ }│{1:~ }|*6
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
command('let &diffopt = &diffopt')
|
||||||
|
screen:expect_unchanged()
|
||||||
|
end)
|
||||||
|
|
||||||
it('does not crash if --embed is given twice', function()
|
it('does not crash if --embed is given twice', function()
|
||||||
clear { args = { '--embed' } }
|
clear { args = { '--embed' } }
|
||||||
assert_alive()
|
assert_alive()
|
||||||
|
31
test/functional/fixtures/diff/startup_new.txt
Normal file
31
test/functional/fixtures/diff/startup_new.txt
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func compressString(str string) string {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeDuplicate(str string) string {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
func reverseAndDouble(str string) string {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
func printCharacters(str string) string {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
hello := "Hello, World!"
|
||||||
|
|
||||||
|
fmt.Print(compressString("aaaabbccgh"))
|
||||||
|
fmt.Print(compressString("golang"))
|
||||||
|
fmt.Print(removeDuplicate("aabccchbbccaaa"))
|
||||||
|
fmt.Print(reverseAndDouble("abcdfgh"))
|
||||||
|
fmt.Print(printCharacters("golang"))
|
||||||
|
|
||||||
|
fmt.Println(hello)
|
||||||
|
}
|
27
test/functional/fixtures/diff/startup_old.txt
Normal file
27
test/functional/fixtures/diff/startup_old.txt
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func compressString(str string) string {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeDuplicate(str string) string {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
func reverseAndDouble(str string) string {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
func printCharacters(str string) string {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.PrintLn(compressString("aaaabbccgh"))
|
||||||
|
fmt.PrintLn(compressString("golang"))
|
||||||
|
fmt.PrintLn(removeDuplicate("aabccchbbccaaa"))
|
||||||
|
fmt.PrintLn(reverseAndDouble("abcdfgh"))
|
||||||
|
fmt.PrintLn(printCharacters("golang"))
|
||||||
|
}
|
@@ -1249,6 +1249,7 @@ end)
|
|||||||
it('diff updates line numbers below filler lines', function()
|
it('diff updates line numbers below filler lines', function()
|
||||||
local screen = Screen.new(40, 14)
|
local screen = Screen.new(40, 14)
|
||||||
exec([[
|
exec([[
|
||||||
|
set diffopt=internal,filler,closeoff
|
||||||
call setline(1, ['a', 'a', 'a', 'y', 'b', 'b', 'b', 'b', 'b'])
|
call setline(1, ['a', 'a', 'a', 'y', 'b', 'b', 'b', 'b', 'b'])
|
||||||
vnew
|
vnew
|
||||||
call setline(1, ['a', 'a', 'a', 'x', 'x', 'x', 'b', 'b', 'b', 'b', 'b'])
|
call setline(1, ['a', 'a', 'a', 'x', 'x', 'x', 'b', 'b', 'b', 'b', 'b'])
|
||||||
@@ -1384,6 +1385,7 @@ end)
|
|||||||
|
|
||||||
it("'relativenumber' doesn't draw beyond end of window in diff mode #29403", function()
|
it("'relativenumber' doesn't draw beyond end of window in diff mode #29403", function()
|
||||||
local screen = Screen.new(60, 12)
|
local screen = Screen.new(60, 12)
|
||||||
|
command('set diffopt=internal,filler,closeoff')
|
||||||
command('set relativenumber')
|
command('set relativenumber')
|
||||||
feed('10aa<CR><Esc>gg')
|
feed('10aa<CR><Esc>gg')
|
||||||
command('vnew')
|
command('vnew')
|
||||||
|
Reference in New Issue
Block a user