mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.0.0149: :earlier does not work after reading the undo file
Problem: ":earlier" and ":later" do not work after startup or reading the undo file. Solution: Use absolute time stamps instead of relative to the Vim start time. (Christian Brabandt, Pavel Juhas, closes #1300, closes #1254)
This commit is contained in:
@@ -235,3 +235,31 @@ func Test_insert_expr()
|
|||||||
|
|
||||||
close!
|
close!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_undofile_earlier()
|
||||||
|
" Issue #1254
|
||||||
|
" create undofile with timestamps older than Vim startup time.
|
||||||
|
let t0 = localtime() - 43200
|
||||||
|
call test_settime(t0)
|
||||||
|
new Xfile
|
||||||
|
call feedkeys("ione\<Esc>", 'xt')
|
||||||
|
set ul=100
|
||||||
|
call test_settime(t0 + 1)
|
||||||
|
call feedkeys("otwo\<Esc>", 'xt')
|
||||||
|
set ul=100
|
||||||
|
call test_settime(t0 + 2)
|
||||||
|
call feedkeys("othree\<Esc>", 'xt')
|
||||||
|
set ul=100
|
||||||
|
w
|
||||||
|
wundo Xundofile
|
||||||
|
bwipe!
|
||||||
|
" restore normal timestamps.
|
||||||
|
call test_settime(0)
|
||||||
|
new Xfile
|
||||||
|
rundo Xundofile
|
||||||
|
earlier 1d
|
||||||
|
call assert_equal('', getline(1))
|
||||||
|
bwipe!
|
||||||
|
call delete('Xfile')
|
||||||
|
call delete('Xundofile')
|
||||||
|
endfunc
|
||||||
|
@@ -2298,10 +2298,8 @@ undo_time(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* When doing computations with time_t subtract starttime, because
|
|
||||||
* time_t converted to a long may result in a wrong number. */
|
|
||||||
if (dosec)
|
if (dosec)
|
||||||
target = (long)(curbuf->b_u_time_cur - starttime) + step;
|
target = (long)(curbuf->b_u_time_cur) + step;
|
||||||
else if (dofile)
|
else if (dofile)
|
||||||
{
|
{
|
||||||
if (step < 0)
|
if (step < 0)
|
||||||
@@ -2350,7 +2348,7 @@ undo_time(
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (dosec)
|
if (dosec)
|
||||||
closest = (long)(vim_time() - starttime + 1);
|
closest = (long)(vim_time() + 1);
|
||||||
else if (dofile)
|
else if (dofile)
|
||||||
closest = curbuf->b_u_save_nr_last + 2;
|
closest = curbuf->b_u_save_nr_last + 2;
|
||||||
else
|
else
|
||||||
@@ -2388,7 +2386,7 @@ undo_time(
|
|||||||
{
|
{
|
||||||
uhp->uh_walk = mark;
|
uhp->uh_walk = mark;
|
||||||
if (dosec)
|
if (dosec)
|
||||||
val = (long)(uhp->uh_time - starttime);
|
val = (long)(uhp->uh_time);
|
||||||
else if (dofile)
|
else if (dofile)
|
||||||
val = uhp->uh_save_nr;
|
val = uhp->uh_save_nr;
|
||||||
else
|
else
|
||||||
|
@@ -764,6 +764,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
149,
|
||||||
/**/
|
/**/
|
||||||
148,
|
148,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user