Fix preview and undo hunk for dos line endings

This commit is contained in:
Andy Stewart
2019-10-14 09:57:46 +01:00
parent 1725c13add
commit 320b7a33e7
3 changed files with 54 additions and 2 deletions

10
test/fixture_dos.txt Normal file
View File

@@ -0,0 +1,10 @@
a
b
c
d
e
f
g
h
i
j

View File

@@ -55,6 +55,7 @@ function SetUp()
call system("git init ".s:test_repo.
\ " && cd ".s:test_repo.
\ " && cp ../fixture.txt .".
\ " && cp ../fixture_dos.txt .".
\ " && git add . && git commit -m 'initial'".
\ " && git config diff.mnemonicPrefix false")
execute ':cd' s:test_repo
@@ -349,6 +350,34 @@ function Test_hunk_outside_noop()
endfunction
function Test_preview_foo()
normal 5Gi*
GitGutterPreviewHunk
wincmd P
call assert_equal(2, line('$'))
call assert_equal('-e', getline(1))
call assert_equal('+*e', getline(2))
wincmd p
endfunction
function Test_preview_dos_foo()
edit! fixture_dos.txt
normal 5Gi*
GitGutterPreviewHunk
wincmd P
call assert_equal(2, line('$'))
call assert_equal('-e', getline(1))
call assert_equal('+*e', getline(2))
wincmd p
endfunction
function Test_hunk_stage()
let _shell = &shell
set shell=foo
@@ -657,6 +686,19 @@ function Test_hunk_undo()
endfunction
function Test_hunk_undo_dos()
edit! fixture_dos.txt
normal 5Gi*
GitGutterUndoHunk
call s:assert_signs([], 'fixture_dos.txt')
call assert_equal([], s:git_diff())
call assert_equal([], s:git_diff_staged())
call assert_equal('e', getline(5))
endfunction
function Test_undo_nearby_hunk()
execute "normal! 2Gox\<CR>y\<CR>z"
normal 2jdd