To: vim-dev@vim.org Subject: Patch 5.6.054 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.6.054 Problem: When using ":e" and ":e #" the cursor is put in the first column when 'startofline' is set. (Cordell) Solution: Use the last known column when 'startofline' is set. Also, use ECMD_LAST more often to simplify the code. Files: src/buffer.c, src/ex_cmds.c, src/ex_docmd.c, src/proto/buffer.pro *** ../vim-5.6.53/src/buffer.c Wed Jan 26 12:20:20 2000 --- src/buffer.c Tue Apr 4 16:28:34 2000 *************** *** 30,36 **** static char_u *buflist_match __ARGS((vim_regexp *prog, BUF *buf)); static char_u *buflist_match_try __ARGS((vim_regexp *prog, char_u *name)); static void buflist_setfpos __ARGS((BUF *, linenr_t, colnr_t)); - static FPOS *buflist_findfpos __ARGS((BUF *buf)); #ifdef UNIX static int otherfile_buf __ARGS((BUF *buf, char_u *ffname, struct stat *stp)); static void buf_setino __ARGS((BUF *buf)); --- 30,35 ---- *************** *** 1423,1429 **** * find the position (lnum and col) for the buffer 'buf' for the current window * returns a pointer to no_position if no position is found */ ! static FPOS * buflist_findfpos(buf) BUF *buf; { --- 1422,1428 ---- * find the position (lnum and col) for the buffer 'buf' for the current window * returns a pointer to no_position if no position is found */ ! FPOS * buflist_findfpos(buf) BUF *buf; { *** ../vim-5.6.53/src/ex_cmds.c Thu Mar 30 16:44:47 2000 --- src/ex_cmds.c Tue Apr 4 16:25:26 2000 *************** *** 2294,2299 **** --- 2294,2301 ---- linenr_t lnum; linenr_t topline = 0; int newcol = -1; + int solcol = -1; + FPOS *pos; if (fnum != 0) { *************** *** 2417,2423 **** /* May jump to last used line number for a loaded buffer or when asked * for explicitly */ if ((oldbuf && newlnum == ECMD_LASTL) || newlnum == ECMD_LAST) ! newlnum = buflist_findlnum(buf); /* * Make the (new) buffer the one used by the current window. --- 2419,2429 ---- /* May jump to last used line number for a loaded buffer or when asked * for explicitly */ if ((oldbuf && newlnum == ECMD_LASTL) || newlnum == ECMD_LAST) ! { ! pos = buflist_findfpos(buf); ! newlnum = pos->lnum; ! solcol = pos->col; ! } /* * Make the (new) buffer the one used by the current window. *************** *** 2514,2520 **** --- 2520,2529 ---- { set_last_cursor(curwin); /* may set b_last_cursor */ if (newlnum == ECMD_LAST || newlnum == ECMD_LASTL) + { newlnum = curwin->w_cursor.lnum; + solcol = curwin->w_cursor.col; + } #ifdef AUTOCMD buf = curbuf; if (buf->b_fname != NULL) *************** *** 2651,2657 **** { curwin->w_cursor.lnum = newlnum; check_cursor_lnum(); ! beginline(BL_SOL | BL_FIX); } else /* no line number, go to last line in Ex mode */ { --- 2660,2673 ---- { curwin->w_cursor.lnum = newlnum; check_cursor_lnum(); ! if (solcol >= 0 && !p_sol) ! { ! /* 'sol' is off: Use last known column. */ ! curwin->w_cursor.col = solcol; ! check_cursor_col(); ! } ! else ! beginline(BL_SOL | BL_FIX); } else /* no line number, go to last line in Ex mode */ { *** ../vim-5.6.53/src/ex_docmd.c Mon Apr 3 09:38:10 2000 --- src/ex_docmd.c Tue Apr 4 16:52:08 2000 *************** *** 5848,5855 **** { int other; char_u *p; - char_u *ffname; - BUF *buf; if (argn < 0 || argn >= arg_file_count) { --- 5851,5856 ---- *************** *** 5894,5916 **** if (argn == arg_file_count - 1) arg_had_last = TRUE; ! /* ! * If no line number given, use the last known line number. ! */ ! if (eap->do_ecmd_lnum == 0) ! { ! ffname = fix_fname(arg_files[curwin->w_arg_idx]); ! if (ffname != NULL) ! { ! buf = buflist_findname(ffname); ! if (buf != NULL) ! eap->do_ecmd_lnum = buflist_findlnum(buf); ! vim_free(ffname); ! } ! } ! (void)do_ecmd(0, arg_files[curwin->w_arg_idx], ! NULL, eap->do_ecmd_cmd, eap->do_ecmd_lnum, (p_hid ? ECMD_HIDE : 0) + (eap->forceit ? ECMD_FORCEIT : 0)); } --- 5895,5903 ---- if (argn == arg_file_count - 1) arg_had_last = TRUE; ! /* Edit the file; always use the last known line number. */ (void)do_ecmd(0, arg_files[curwin->w_arg_idx], ! NULL, eap->do_ecmd_cmd, ECMD_LAST, (p_hid ? ECMD_HIDE : 0) + (eap->forceit ? ECMD_FORCEIT : 0)); } *************** *** 7534,7540 **** return NULL; } if (lnump != NULL) ! *lnump = buflist_findlnum(buf); if (buf->b_fname == NULL) { result = (char_u *)""; --- 7521,7527 ---- return NULL; } if (lnump != NULL) ! *lnump = ECMD_LAST; if (buf->b_fname == NULL) { result = (char_u *)""; *************** *** 7652,7658 **** char_u *repl; int srclen; char_u *p; - linenr_t dummy; result = vim_strsave(arg); if (result == NULL) --- 7639,7644 ---- *************** *** 7665,7671 **** else { /* replace "" with the sourced file name, and do ":" stuff */ ! repl = eval_vars(p, &srclen, &dummy, &errormsg, result); if (errormsg != NULL) { if (*errormsg) --- 7651,7657 ---- else { /* replace "" with the sourced file name, and do ":" stuff */ ! repl = eval_vars(p, &srclen, NULL, &errormsg, result); if (errormsg != NULL) { if (*errormsg) *** ../vim-5.6.53/src/proto/buffer.pro Sun Jan 16 14:22:13 2000 --- src/proto/buffer.pro Tue Apr 4 16:27:04 2000 *************** *** 16,21 **** --- 16,22 ---- int ExpandBufnames __ARGS((char_u *pat, int *num_file, char_u ***file, int options)); BUF *buflist_findnr __ARGS((int nr)); char_u *buflist_nr2name __ARGS((int n, int fullname, int helptail)); + FPOS *buflist_findfpos __ARGS((BUF *buf)); linenr_t buflist_findlnum __ARGS((BUF *buf)); void buflist_list __ARGS((void)); int buflist_name_nr __ARGS((int fnum, char_u **fname, linenr_t *lnum)); *** ../vim-5.6.53/src/version.c Mon Apr 3 21:11:14 2000 --- src/version.c Tue Apr 4 17:06:54 2000 *************** *** 420,421 **** --- 420,423 ---- { /* Add new patch number below this line */ + /**/ + 54, /**/ -- INSPECTOR END OF FILM: Move along. There's nothing to see! Keep moving! [Suddenly he notices the cameras.] INSPECTOR END OF FILM: (to Camera) All right, put that away sonny. [He walks over to it and puts his hand over the lens.] "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\ \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/