comparison src/edit.c @ 6712:c939d19bd86e v7.4.680

updated for version 7.4.680 Problem: CTRL-W in Insert mode does not work well for multi-byte characters. Solution: Use mb_get_class(). (Yasuhiro Matsumoto)
author Bram Moolenaar <bram@vim.org>
date Tue, 24 Mar 2015 17:49:51 +0100
parents 97cc4ee3e095
children e25417c299bb
comparison
equal deleted inserted replaced
6711:746596b122c8 6712:c939d19bd86e
9045 } 9045 }
9046 9046
9047 /* 9047 /*
9048 * Delete upto starting point, start of line or previous word. 9048 * Delete upto starting point, start of line or previous word.
9049 */ 9049 */
9050 else do 9050 else
9051 { 9051 {
9052 #ifdef FEAT_RIGHTLEFT 9052 #ifdef FEAT_MBYTE
9053 if (!revins_on) /* put cursor on char to be deleted */ 9053 int cclass = 0, prev_cclass = 0;
9054 #endif 9054
9055 dec_cursor(); 9055 if (has_mbyte)
9056 9056 cclass = mb_get_class(ml_get_cursor());
9057 /* start of word? */ 9057 #endif
9058 if (mode == BACKSPACE_WORD && !vim_isspace(gchar_cursor())) 9058 do
9059 {
9060 mode = BACKSPACE_WORD_NOT_SPACE;
9061 temp = vim_iswordc(gchar_cursor());
9062 }
9063 /* end of word? */
9064 else if (mode == BACKSPACE_WORD_NOT_SPACE
9065 && (vim_isspace(cc = gchar_cursor())
9066 || vim_iswordc(cc) != temp))
9067 { 9059 {
9068 #ifdef FEAT_RIGHTLEFT 9060 #ifdef FEAT_RIGHTLEFT
9069 if (!revins_on) 9061 if (!revins_on) /* put cursor on char to be deleted */
9070 #endif 9062 #endif
9071 inc_cursor(); 9063 dec_cursor();
9064
9065 cc = gchar_cursor();
9066 #ifdef FEAT_MBYTE
9067 /* look multi-byte character class */
9068 if (has_mbyte)
9069 {
9070 prev_cclass = cclass;
9071 cclass = mb_get_class(ml_get_cursor());
9072 }
9073 #endif
9074
9075 /* start of word? */
9076 if (mode == BACKSPACE_WORD && !vim_isspace(cc))
9077 {
9078 mode = BACKSPACE_WORD_NOT_SPACE;
9079 temp = vim_iswordc(cc);
9080 }
9081 /* end of word? */
9082 else if (mode == BACKSPACE_WORD_NOT_SPACE
9083 && ((vim_isspace(cc) || vim_iswordc(cc) != temp)
9084 #ifdef FEAT_MBYTE
9085 || prev_cclass != cclass
9086 #endif
9087 ))
9088 {
9072 #ifdef FEAT_RIGHTLEFT 9089 #ifdef FEAT_RIGHTLEFT
9073 else if (State & REPLACE_FLAG) 9090 if (!revins_on)
9074 dec_cursor(); 9091 #endif
9075 #endif 9092 inc_cursor();
9076 break; 9093 #ifdef FEAT_RIGHTLEFT
9077 } 9094 else if (State & REPLACE_FLAG)
9078 if (State & REPLACE_FLAG) 9095 dec_cursor();
9079 replace_do_bs(-1); 9096 #endif
9080 else 9097 break;
9081 { 9098 }
9099 if (State & REPLACE_FLAG)
9100 replace_do_bs(-1);
9101 else
9102 {
9082 #ifdef FEAT_MBYTE 9103 #ifdef FEAT_MBYTE
9083 if (enc_utf8 && p_deco) 9104 if (enc_utf8 && p_deco)
9084 (void)utfc_ptr2char(ml_get_cursor(), cpc); 9105 (void)utfc_ptr2char(ml_get_cursor(), cpc);
9085 #endif 9106 #endif
9086 (void)del_char(FALSE); 9107 (void)del_char(FALSE);
9087 #ifdef FEAT_MBYTE 9108 #ifdef FEAT_MBYTE
9088 /* 9109 /*
9089 * If there are combining characters and 'delcombine' is set 9110 * If there are combining characters and 'delcombine' is set
9090 * move the cursor back. Don't back up before the base 9111 * move the cursor back. Don't back up before the base
9091 * character. 9112 * character.
9092 */ 9113 */
9093 if (enc_utf8 && p_deco && cpc[0] != NUL) 9114 if (enc_utf8 && p_deco && cpc[0] != NUL)
9094 inc_cursor(); 9115 inc_cursor();
9095 #endif 9116 #endif
9096 #ifdef FEAT_RIGHTLEFT 9117 #ifdef FEAT_RIGHTLEFT
9097 if (revins_chars) 9118 if (revins_chars)
9098 { 9119 {
9099 revins_chars--; 9120 revins_chars--;
9100 revins_legal++; 9121 revins_legal++;
9122 }
9123 if (revins_on && gchar_cursor() == NUL)
9124 break;
9125 #endif
9101 } 9126 }
9102 if (revins_on && gchar_cursor() == NUL) 9127 /* Just a single backspace?: */
9128 if (mode == BACKSPACE_CHAR)
9103 break; 9129 break;
9104 #endif 9130 } while (
9105 }
9106 /* Just a single backspace?: */
9107 if (mode == BACKSPACE_CHAR)
9108 break;
9109 } while (
9110 #ifdef FEAT_RIGHTLEFT 9131 #ifdef FEAT_RIGHTLEFT
9111 revins_on || 9132 revins_on ||
9112 #endif 9133 #endif
9113 (curwin->w_cursor.col > mincol 9134 (curwin->w_cursor.col > mincol
9114 && (curwin->w_cursor.lnum != Insstart_orig.lnum 9135 && (curwin->w_cursor.lnum != Insstart_orig.lnum
9115 || curwin->w_cursor.col != Insstart_orig.col))); 9136 || curwin->w_cursor.col != Insstart_orig.col)));
9137 }
9116 did_backspace = TRUE; 9138 did_backspace = TRUE;
9117 } 9139 }
9118 #ifdef FEAT_SMARTINDENT 9140 #ifdef FEAT_SMARTINDENT
9119 did_si = FALSE; 9141 did_si = FALSE;
9120 can_si = FALSE; 9142 can_si = FALSE;