clipboard: handle middle-click paste correctly.

Also handle clipboard errors more like vim: paste from unnamed register
if clipboard provider fails.
This commit is contained in:
Björn Linse 2015-07-15 13:59:05 +02:00 committed by Justin M. Keyes
parent 0e39b2c936
commit c30f2ac25d
2 changed files with 10 additions and 1 deletions

View File

@ -2016,6 +2016,9 @@ do_mouse (
if (regname == '.')
insert_reg(regname, true);
else {
if (regname == 0 && eval_has_provider("clipboard")) {
regname = '*';
}
if ((State & REPLACE_FLAG) && !yank_register_mline(regname))
insert_reg(regname, true);
else {
@ -2279,6 +2282,9 @@ do_mouse (
* Middle mouse click: Put text before cursor.
*/
if (which_button == MOUSE_MIDDLE) {
if (regname == 0 && eval_has_provider("clipboard")) {
regname = '*';
}
if (yank_register_mline(regname)) {
if (mouse_past_bottom)
dir = FORWARD;

View File

@ -765,7 +765,10 @@ yankreg_T *get_yank_register(int regname, int mode)
if (mode == YREG_PASTE && get_clipboard(regname, &reg, false)) {
// reg is set to clipboard contents.
return reg;
} else if (mode != YREG_YANK && (regname == 0 || regname == '"') && y_previous != NULL) {
} else if (mode != YREG_YANK
&& (regname == 0 || regname == '"' || regname == '*' || regname == '+')
&& y_previous != NULL) {
// in case clipboard not available, paste from previous used register
return y_previous;
}