To: vim_dev@googlegroups.com Subject: Patch 8.0.0149 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0149 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) Files: src/testdir/test_undo.vim, src/undo.c *** ../vim-8.0.0148/src/undo.c 2016-11-10 20:01:41.201582868 +0100 --- src/undo.c 2017-01-07 16:07:07.561481836 +0100 *************** *** 2298,2307 **** } else { - /* When doing computations with time_t subtract starttime, because - * time_t converted to a long may result in a wrong number. */ if (dosec) ! target = (long)(curbuf->b_u_time_cur - starttime) + step; else if (dofile) { if (step < 0) --- 2298,2305 ---- } else { if (dosec) ! target = (long)(curbuf->b_u_time_cur) + step; else if (dofile) { if (step < 0) *************** *** 2350,2356 **** else { if (dosec) ! closest = (long)(vim_time() - starttime + 1); else if (dofile) closest = curbuf->b_u_save_nr_last + 2; else --- 2348,2354 ---- else { if (dosec) ! closest = (long)(vim_time() + 1); else if (dofile) closest = curbuf->b_u_save_nr_last + 2; else *************** *** 2388,2394 **** { uhp->uh_walk = mark; if (dosec) ! val = (long)(uhp->uh_time - starttime); else if (dofile) val = uhp->uh_save_nr; else --- 2386,2392 ---- { uhp->uh_walk = mark; if (dosec) ! val = (long)(uhp->uh_time); else if (dofile) val = uhp->uh_save_nr; else *** ../vim-8.0.0148/src/testdir/test_undo.vim 2016-08-31 20:30:21.000000000 +0200 --- src/testdir/test_undo.vim 2017-01-07 15:54:36.491066617 +0100 *************** *** 235,237 **** --- 235,265 ---- close! 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\", 'xt') + set ul=100 + call test_settime(t0 + 1) + call feedkeys("otwo\", 'xt') + set ul=100 + call test_settime(t0 + 2) + call feedkeys("othree\", '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 *** ../vim-8.0.0148/src/version.c 2017-01-07 15:39:36.401759496 +0100 --- src/version.c 2017-01-07 16:13:59.142424882 +0100 *************** *** 766,767 **** --- 766,769 ---- { /* Add new patch number below this line */ + /**/ + 149, /**/ -- $ echo pizza > /dev/oven /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///