mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #27971 from zeertzjq/vim-9.1.0192
vim-patch:9.1.{0192,0195}: drop: don't rewind when editing the same file
This commit is contained in:
commit
50b2499306
@ -866,11 +866,13 @@ void ex_drop(exarg_T *eap)
|
|||||||
const int save_ar = curbuf->b_p_ar;
|
const int save_ar = curbuf->b_p_ar;
|
||||||
|
|
||||||
// reload the file if it is newer
|
// reload the file if it is newer
|
||||||
curbuf->b_p_ar = 1;
|
curbuf->b_p_ar = true;
|
||||||
buf_check_timestamp(curbuf);
|
buf_check_timestamp(curbuf);
|
||||||
curbuf->b_p_ar = save_ar;
|
curbuf->b_p_ar = save_ar;
|
||||||
}
|
}
|
||||||
|
if (curbuf->b_ml.ml_flags & ML_EMPTY) {
|
||||||
ex_rewind(eap);
|
ex_rewind(eap);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
|
|||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local clear, feed, feed_command = helpers.clear, helpers.feed, helpers.feed_command
|
local clear, feed, feed_command = helpers.clear, helpers.feed, helpers.feed_command
|
||||||
|
local exec = helpers.exec
|
||||||
|
|
||||||
describe(':drop', function()
|
describe(':drop', function()
|
||||||
local screen
|
local screen
|
||||||
@ -16,7 +17,7 @@ describe(':drop', function()
|
|||||||
[2] = { reverse = true },
|
[2] = { reverse = true },
|
||||||
[3] = { bold = true },
|
[3] = { bold = true },
|
||||||
})
|
})
|
||||||
command('set laststatus=2 shortmess-=F')
|
command('set nohidden laststatus=2 shortmess-=F')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works like :e when called with only one window open', function()
|
it('works like :e when called with only one window open', function()
|
||||||
@ -43,7 +44,6 @@ describe(':drop', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it("splits off a new window when a buffer can't be abandoned", function()
|
it("splits off a new window when a buffer can't be abandoned", function()
|
||||||
command('set nohidden')
|
|
||||||
feed_command('edit tmp1')
|
feed_command('edit tmp1')
|
||||||
feed_command('vsplit')
|
feed_command('vsplit')
|
||||||
feed_command('edit tmp2')
|
feed_command('edit tmp2')
|
||||||
@ -59,4 +59,20 @@ describe(':drop', function()
|
|||||||
"tmp3" [New] |
|
"tmp3" [New] |
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- oldtest: Test_drop_modified_file()
|
||||||
|
it('does not cause E37 with modified same file', function()
|
||||||
|
exec([[
|
||||||
|
edit Xdrop_modified.txt
|
||||||
|
call setline(1, 'The quick brown fox jumped over the lazy dogs')
|
||||||
|
]])
|
||||||
|
feed_command('drop Xdrop_modified.txt')
|
||||||
|
screen:expect([[
|
||||||
|
^The quick brown fox jumped over the|
|
||||||
|
lazy dogs |
|
||||||
|
{0:~ }|*6
|
||||||
|
{1:Xdrop_modified.txt [+] }|
|
||||||
|
:drop Xdrop_modified.txt |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
source check.vim
|
source check.vim
|
||||||
source shared.vim
|
source shared.vim
|
||||||
source term_util.vim
|
source term_util.vim
|
||||||
|
source screendump.vim
|
||||||
|
|
||||||
func Test_ex_delete()
|
func Test_ex_delete()
|
||||||
new
|
new
|
||||||
@ -758,4 +759,19 @@ func Test_ex_address_range_overflow()
|
|||||||
call assert_fails(':--+foobar', 'E492:')
|
call assert_fails(':--+foobar', 'E492:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_drop_modified_file()
|
||||||
|
CheckScreendump
|
||||||
|
let lines =<< trim END
|
||||||
|
call setline(1, 'The quick brown fox jumped over the lazy dogs')
|
||||||
|
END
|
||||||
|
call writefile([''], 'Xdrop_modified.txt', 'D')
|
||||||
|
call writefile(lines, 'Xtest_drop_modified', 'D')
|
||||||
|
let buf = RunVimInTerminal('-S Xtest_drop_modified Xdrop_modified.txt', {'rows': 10,'columns': 40})
|
||||||
|
call term_sendkeys(buf, ":drop Xdrop_modified.txt\<CR>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_drop_modified_1', {})
|
||||||
|
|
||||||
|
" clean up
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Loading…
Reference in New Issue
Block a user