To: vim-dev@vim.org Subject: Patch 6.1.413 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.413 Problem: When 'clipboard' contains "unnamed", "p" in Visual mode doesn't work correctly. Solution: Save the register before overwriting it and put the resulting text on the clipboard afterwards. (Muraoka Taro) Files: src/normal.c, src/ops.c *** ../vim61.412/src/normal.c Sat Mar 15 17:55:18 2003 --- src/normal.c Thu Mar 20 21:37:09 2003 *************** *** 8048,8054 **** # ifdef FEAT_CLIPBOARD adjust_clip_reg(®name); # endif ! if (regname == 0 || isdigit(regname)) { /* the delete is going to overwrite the register we want to * put, save it first. */ --- 8048,8059 ---- # ifdef FEAT_CLIPBOARD adjust_clip_reg(®name); # endif ! if (regname == 0 || isdigit(regname) ! # ifdef FEAT_CLIPBOARD ! || (clip_unnamed && (regname == '*' || regname == '+')) ! # endif ! ! ) { /* the delete is going to overwrite the register we want to * put, save it first. */ *** ../vim61.412/src/ops.c Sun Feb 16 20:14:02 2003 --- src/ops.c Sun Mar 23 21:05:02 2003 *************** *** 104,109 **** --- 104,112 ---- static int yank_copy_line __ARGS((struct block_def *bd, long y_idx)); #ifdef FEAT_CLIPBOARD static void copy_yank_reg __ARGS((struct yankreg *reg)); + # if defined(FEAT_VISUAL) || defined(FEAT_EVAL) + static void may_set_selection __ARGS((void)); + # endif #endif static void dis_msg __ARGS((char_u *p, int skip_esc)); #ifdef FEAT_VISUAL *************** *** 894,899 **** --- 897,907 ---- get_yank_register(name, 0); free_yank_all(); *y_current = *(struct yankreg *)reg; + + # ifdef FEAT_CLIPBOARD + /* Send text written to clipboard register to the clipboard. */ + may_set_selection(); + # endif } #endif *************** *** 5225,5234 **** return y_ptr->y_type; } - #endif /* FEAT_CLIPBOARD || PROTO */ ! #ifdef FEAT_EVAL /* * Return the contents of a register as a single allocated string. * Used for "@r" in expressions. --- 5233,5262 ---- return y_ptr->y_type; } + # if defined(FEAT_VISUAL) || defined(FEAT_EVAL) + /* + * If we have written to a clipboard register, send the text to the clipboard. + */ + static void + may_set_selection() + { + if (y_current == &(y_regs[STAR_REGISTER]) && clip_star.available) + { + clip_own_selection(&clip_star); + clip_gen_set_selection(&clip_star); + } + else if (y_current == &(y_regs[PLUS_REGISTER]) && clip_plus.available) + { + clip_own_selection(&clip_plus); + clip_gen_set_selection(&clip_plus); + } + } + # endif + + #endif /* FEAT_CLIPBOARD || PROTO */ ! #if defined(FEAT_EVAL) || defined(PROTO) /* * Return the contents of a register as a single allocated string. * Used for "@r" in expressions. *************** *** 5369,5392 **** (len > 0 && (str[len - 1] == '\n' || str[len -1] == '\r')) ? MLINE : MCHAR, str, len); ! #ifdef FEAT_CLIPBOARD ! /* ! * If we are writing to the selection register, send result to selection. ! */ ! if (y_current == &(y_regs[STAR_REGISTER]) && clip_star.available) ! { ! clip_own_selection(&clip_star); ! clip_gen_set_selection(&clip_star); ! } ! /* ! * If we are writing to the clipboard register, send result to clipboard. ! */ ! else if (y_current == &(y_regs[PLUS_REGISTER]) && clip_plus.available) ! { ! clip_own_selection(&clip_plus); ! clip_gen_set_selection(&clip_plus); ! } ! #endif /* ':let @" = "val"' should change the meaning of the "" register */ if (name != '"') --- 5397,5406 ---- (len > 0 && (str[len - 1] == '\n' || str[len -1] == '\r')) ? MLINE : MCHAR, str, len); ! # ifdef FEAT_CLIPBOARD ! /* Send text of clipboard register to the clipboard. */ ! may_set_selection(); ! # endif /* ':let @" = "val"' should change the meaning of the "" register */ if (name != '"') *** ../vim61.412/src/version.c Sun Mar 23 20:55:21 2003 --- src/version.c Sun Mar 23 20:59:51 2003 *************** *** 613,614 **** --- 613,616 ---- { /* Add new patch number below this line */ + /**/ + 413, /**/ -- hundred-and-one symptoms of being an internet addict: 182. You may not know what is happening in the world, but you know every bit of net-gossip there is. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///