To: vim-dev@vim.org Subject: Patch 5.6.085 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.6.085 Problem: Multi-byte: Using "r" to replace a double-byte char with a single-byte char moved the cursor one character. (Matsumoto) Also, using a count when replacing a single-byte char with a double-byte char didn't work. Solution: Don't use del_char() to delete the second byte. Get "ptr" again after calling ins_char(). Files: src/normal.c *** ../vim-5.6.84/src/normal.c Wed Apr 12 19:04:03 2000 --- src/normal.c Mon Apr 17 09:58:21 2000 *************** *** 4521,4539 **** /* Handle three situations: * 1. replace double-byte with double-byte: set trailbyte. * 2. replace single-byte with double-byte: insert trailbyte. ! * 3. replace double-byte with single-bute: delete char. */ if (trailbyte != NUL) { if (IsLeadByte(prechar)) ptr[curwin->w_cursor.col] = trailbyte; else (void)ins_char(trailbyte); } else if (IsLeadByte(prechar)) { ! (void)del_char(TRUE); ! ++curwin->w_cursor.col; } } #endif --- 4520,4548 ---- /* Handle three situations: * 1. replace double-byte with double-byte: set trailbyte. * 2. replace single-byte with double-byte: insert trailbyte. ! * 3. replace double-byte with single-byte: delete char. */ if (trailbyte != NUL) { if (IsLeadByte(prechar)) + { ptr[curwin->w_cursor.col] = trailbyte; + ++curwin->w_cursor.col; + } else + { (void)ins_char(trailbyte); + if (n > 1) + /* pointer will have changed, get it again */ + ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, + TRUE); + } } else if (IsLeadByte(prechar)) { ! mch_memmove(ptr + curwin->w_cursor.col, ! ptr + curwin->w_cursor.col + 1, ! STRLEN(ptr + curwin->w_cursor.col)); } } #endif *** ../vim-5.6.84/src/version.c Mon Jun 5 12:11:59 2000 --- src/version.c Mon Jun 5 12:13:33 2000 *************** *** 420,421 **** --- 420,423 ---- { /* Add new patch number below this line */ + /**/ + 85, /**/ -- THEOREM: VI is perfect. PROOF: VI in roman numerals is 6. The natural numbers < 6 which divide 6 are 1, 2, and 3. 1+2+3 = 6. So 6 is a perfect number. Therefore, VI is perfect. QED -- Arthur Tateishi /-/-- Bram Moolenaar --- Bram@moolenaar.net --- http://www.moolenaar.net --\-\ \-\-- Vim: http://www.vim.org ---- ICCF Holland: http://www.vim.org/iccf --/-/