Compatibility problem about "." register.

28 views
Skip to first unread message

mattn

unread,
Jan 28, 2012, 9:58:33 AM1/28/12
to vim...@googlegroups.com
I got a bug report about behavior of "." register in compatible mode. When typed commands fail with "an Empty region", original behavior is that don't store
last commands to "." register.

For example:

vim -u NONE
:set cpoptions+=E
afoo<ESC>0c0

You will get beep. This mean "an Empty region". If you type ".", you'll get an error again. But traditional vi's behavior is repeat of append "foo". Then text should be:

ffoooo

Another example:

vim -u NONE
:set cpoptions+=E
ahoge<ESC>c0:q!<CR><ESC>

Text will be:

q!
e

Then, type "."

Original vi's behavior will not do anything. But vim will exit. This cause that vim don't clear "." register when error occur.

Below is a patch. Please check and include. This patch is written by Hideki EIRAKU.


diff -ur vim/src/getchar.c hdk1983-vim/src/getchar.c
--- vim/src/getchar.c 2012-01-15 22:06:34.240016219 +0900
+++ hdk1983-vim/src/getchar.c 2012-01-28 23:11:36.900123501 +0900
@@ -470,6 +470,20 @@
     }
 }
 
+    void
+CancelRedo()
+{
+    if (!block_redo)
+    {
+ free_buff(&redobuff);
+ redobuff = old_redobuff;
+ old_redobuff.bh_first.b_next = NULL;
+ start_stuff();
+ while (read_stuff(TRUE) != NUL)
+    ;
+    }
+}
+
 #if defined(FEAT_AUTOCMD) || defined(FEAT_EVAL) || defined(PROTO)
 /*
  * Save redobuff and old_redobuff to save_redobuff and save_old_redobuff.
diff -ur vim/src/normal.c hdk1983-vim/src/normal.c
--- vim/src/normal.c 2012-01-28 22:57:38.583873667 +0900
+++ hdk1983-vim/src/normal.c 2012-01-28 23:11:37.004047958 +0900
@@ -1978,7 +1978,10 @@
     VIsual_reselect = FALSE;    /* don't reselect now */
 #endif
     if (empty_region_error)
+    {
  vim_beep();
+ CancelRedo();
+    }
     else
     {
  (void)op_delete(oap);
@@ -1992,7 +1995,10 @@
     if (empty_region_error)
     {
  if (!gui_yank)
+ {
     vim_beep();
+    CancelRedo();
+ }
     }
     else
  (void)op_yank(oap, FALSE, !gui_yank);
@@ -2004,7 +2010,10 @@
     VIsual_reselect = FALSE;    /* don't reselect now */
 #endif
     if (empty_region_error)
+    {
  vim_beep();
+ CancelRedo();
+    }
     else
     {
  /* This is a new edit command, not a restart.  Need to
@@ -2066,7 +2075,10 @@
  case OP_LOWER:
  case OP_ROT13:
     if (empty_region_error)
+    {
  vim_beep();
+ CancelRedo();
+    }
     else
  op_tilde(oap);
     check_cursor_col();
@@ -2099,7 +2111,10 @@
 #endif
 #ifdef FEAT_VISUALEXTRA
     if (empty_region_error)
+    {
  vim_beep();
+ CancelRedo();
+    }
     else
     {
  /* This is a new edit command, not a restart.  Need to
@@ -2129,7 +2144,10 @@
 #ifdef FEAT_VISUALEXTRA
     if (empty_region_error)
 #endif
+    {
  vim_beep();
+ CancelRedo();
+    }
 #ifdef FEAT_VISUALEXTRA
     else
  op_replace(oap, cap->nchar);
--

Yasuhiro Matsumoto

Bram Moolenaar

unread,
Jan 28, 2012, 12:03:59 PM1/28/12
to mattn, vim...@googlegroups.com

Yasuhiro Matsumoto wrote:

Thanks, I'll add it to the todo list.

Your patches often have indent removed. Would there be a way to avoid
that?

--
hundred-and-one symptoms of being an internet addict:
3. Your bookmark takes 15 minutes to scroll from top to bottom.

/// Bram Moolenaar -- Br...@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 ///

Reply all
Reply to author
Forward
0 new messages