comparison src/edit.c @ 16101:5c5d211bd5a8 v8.1.1055

patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left commit https://github.com/vim/vim/commit/75bf3d22f42684beecd977f3185e98045b5c33d9 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Mar 26 22:46:05 2019 +0100 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left Problem: CTRL-G U in Insert mode doesn't work to avoid splitting the undo sequence for shift-left and shift-right. Solution: Also check dont_sync_undo for shifted cursor keys. (Christian Brabandt)
author Bram Moolenaar <Bram@vim.org>
date Tue, 26 Mar 2019 23:00:06 +0100
parents 78faa25f9698
children 0375e54f0adc
comparison
equal deleted inserted replaced
16100:1c8969addd04 16101:5c5d211bd5a8
234 static void ins_mousescroll(int dir); 234 static void ins_mousescroll(int dir);
235 #endif 235 #endif
236 #if defined(FEAT_GUI_TABLINE) || defined(PROTO) 236 #if defined(FEAT_GUI_TABLINE) || defined(PROTO)
237 static void ins_tabline(int c); 237 static void ins_tabline(int c);
238 #endif 238 #endif
239 static void ins_left(int end_change); 239 static void ins_left(void);
240 static void ins_home(int c); 240 static void ins_home(int c);
241 static void ins_end(int c); 241 static void ins_end(int c);
242 static void ins_s_left(void); 242 static void ins_s_left(void);
243 static void ins_right(int end_change); 243 static void ins_right(void);
244 static void ins_s_right(void); 244 static void ins_s_right(void);
245 static void ins_up(int startcol); 245 static void ins_up(int startcol);
246 static void ins_pageup(void); 246 static void ins_pageup(void);
247 static void ins_down(int startcol); 247 static void ins_down(int startcol);
248 static void ins_pagedown(void); 248 static void ins_pagedown(void);
288 288
289 static int ins_need_undo; /* call u_save() before inserting a 289 static int ins_need_undo; /* call u_save() before inserting a
290 char. Set when edit() is called. 290 char. Set when edit() is called.
291 after that arrow_used is used. */ 291 after that arrow_used is used. */
292 292
293 static int did_add_space = FALSE; /* auto_format() added an extra space 293 static int did_add_space = FALSE; // auto_format() added an extra space
294 under the cursor */ 294 // under the cursor
295 static int dont_sync_undo = FALSE; /* CTRL-G U prevents syncing undo for 295 static int dont_sync_undo = FALSE; // CTRL-G U prevents syncing undo for
296 the next left/right cursor */ 296 // the next left/right cursor key
297 297
298 /* 298 /*
299 * edit(): Start inserting text. 299 * edit(): Start inserting text.
300 * 300 *
301 * "cmdchar" can be: 301 * "cmdchar" can be:
1282 1282
1283 case K_LEFT: /* <Left> */ 1283 case K_LEFT: /* <Left> */
1284 if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)) 1284 if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))
1285 ins_s_left(); 1285 ins_s_left();
1286 else 1286 else
1287 ins_left(dont_sync_undo == FALSE); 1287 ins_left();
1288 break; 1288 break;
1289 1289
1290 case K_S_LEFT: /* <S-Left> */ 1290 case K_S_LEFT: /* <S-Left> */
1291 case K_C_LEFT: 1291 case K_C_LEFT:
1292 ins_s_left(); 1292 ins_s_left();
1294 1294
1295 case K_RIGHT: /* <Right> */ 1295 case K_RIGHT: /* <Right> */
1296 if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)) 1296 if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL))
1297 ins_s_right(); 1297 ins_s_right();
1298 else 1298 else
1299 ins_right(dont_sync_undo == FALSE); 1299 ins_right();
1300 break; 1300 break;
1301 1301
1302 case K_S_RIGHT: /* <S-Right> */ 1302 case K_S_RIGHT: /* <S-Right> */
1303 case K_C_RIGHT: 1303 case K_C_RIGHT:
1304 ins_s_right(); 1304 ins_s_right();
9289 } 9289 }
9290 } 9290 }
9291 #endif 9291 #endif
9292 9292
9293 static void 9293 static void
9294 ins_left( 9294 ins_left(void)
9295 int end_change) /* end undoable change */
9296 { 9295 {
9297 pos_T tpos; 9296 pos_T tpos;
9297 int end_change = dont_sync_undo == FALSE; // end undoable change
9298 9298
9299 #ifdef FEAT_FOLDING 9299 #ifdef FEAT_FOLDING
9300 if ((fdo_flags & FDO_HOR) && KeyTyped) 9300 if ((fdo_flags & FDO_HOR) && KeyTyped)
9301 foldOpenCursor(); 9301 foldOpenCursor();
9302 #endif 9302 #endif
9376 9376
9377 start_arrow(&tpos); 9377 start_arrow(&tpos);
9378 } 9378 }
9379 9379
9380 static void 9380 static void
9381 ins_s_left(void) 9381 ins_s_left()
9382 { 9382 {
9383 int end_change = dont_sync_undo == FALSE; // end undoable change
9383 #ifdef FEAT_FOLDING 9384 #ifdef FEAT_FOLDING
9384 if ((fdo_flags & FDO_HOR) && KeyTyped) 9385 if ((fdo_flags & FDO_HOR) && KeyTyped)
9385 foldOpenCursor(); 9386 foldOpenCursor();
9386 #endif 9387 #endif
9387 undisplay_dollar(); 9388 undisplay_dollar();
9388 if (curwin->w_cursor.lnum > 1 || curwin->w_cursor.col > 0) 9389 if (curwin->w_cursor.lnum > 1 || curwin->w_cursor.col > 0)
9389 { 9390 {
9390 start_arrow(&curwin->w_cursor); 9391 start_arrow_with_change(&curwin->w_cursor, end_change);
9392 if (!end_change)
9393 AppendCharToRedobuff(K_S_LEFT);
9391 (void)bck_word(1L, FALSE, FALSE); 9394 (void)bck_word(1L, FALSE, FALSE);
9392 curwin->w_set_curswant = TRUE; 9395 curwin->w_set_curswant = TRUE;
9393 } 9396 }
9394 else 9397 else
9395 vim_beep(BO_CRSR); 9398 vim_beep(BO_CRSR);
9399 dont_sync_undo = FALSE;
9396 } 9400 }
9397 9401
9398 static void 9402 static void
9399 ins_right( 9403 ins_right(void)
9400 int end_change) /* end undoable change */ 9404 {
9401 { 9405 int end_change = dont_sync_undo == FALSE; // end undoable change
9406
9402 #ifdef FEAT_FOLDING 9407 #ifdef FEAT_FOLDING
9403 if ((fdo_flags & FDO_HOR) && KeyTyped) 9408 if ((fdo_flags & FDO_HOR) && KeyTyped)
9404 foldOpenCursor(); 9409 foldOpenCursor();
9405 #endif 9410 #endif
9406 undisplay_dollar(); 9411 undisplay_dollar();
9440 vim_beep(BO_CRSR); 9445 vim_beep(BO_CRSR);
9441 dont_sync_undo = FALSE; 9446 dont_sync_undo = FALSE;
9442 } 9447 }
9443 9448
9444 static void 9449 static void
9445 ins_s_right(void) 9450 ins_s_right()
9446 { 9451 {
9452 int end_change = dont_sync_undo == FALSE; // end undoable change
9447 #ifdef FEAT_FOLDING 9453 #ifdef FEAT_FOLDING
9448 if ((fdo_flags & FDO_HOR) && KeyTyped) 9454 if ((fdo_flags & FDO_HOR) && KeyTyped)
9449 foldOpenCursor(); 9455 foldOpenCursor();
9450 #endif 9456 #endif
9451 undisplay_dollar(); 9457 undisplay_dollar();
9452 if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count 9458 if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count
9453 || gchar_cursor() != NUL) 9459 || gchar_cursor() != NUL)
9454 { 9460 {
9455 start_arrow(&curwin->w_cursor); 9461 start_arrow_with_change(&curwin->w_cursor, end_change);
9462 if (!end_change)
9463 AppendCharToRedobuff(K_S_RIGHT);
9456 (void)fwd_word(1L, FALSE, 0); 9464 (void)fwd_word(1L, FALSE, 0);
9457 curwin->w_set_curswant = TRUE; 9465 curwin->w_set_curswant = TRUE;
9458 } 9466 }
9459 else 9467 else
9460 vim_beep(BO_CRSR); 9468 vim_beep(BO_CRSR);
9469 dont_sync_undo = FALSE;
9461 } 9470 }
9462 9471
9463 static void 9472 static void
9464 ins_up( 9473 ins_up(
9465 int startcol) /* when TRUE move to Insstart.col */ 9474 int startcol) /* when TRUE move to Insstart.col */