Skip to content

Commit 357e941

Browse files
mtaran-googlemarijnh
authored andcommitted
[paste] Fix #2384 and #1883
As described in the comment, there was actually an intermediate selection being created, which clobbered the middle-click paste buffer and thus resulted in a $ being pasted instead of the actual content the user wanted. It's still a mystery why you couldn't repro it, but my guess is that due to some configuration (maybe in your window manager) your system wasn't updating the paste buffer as eagerly as Debian and Unity do by default.
1 parent e5e2e16 commit 357e941

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/codemirror.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2452,8 +2452,12 @@
24522452
if (webkit && !cm.state.fakedLastChar && !(new Date - cm.state.lastMiddleDown < 200)) {
24532453
var start = d.input.selectionStart, end = d.input.selectionEnd;
24542454
d.input.value += "$";
2455-
d.input.selectionStart = start;
2455+
// The selection end needs to be set before the start, otherwise there
2456+
// can be an intermediate non-empty selection between the two, which
2457+
// can override the middle-click paste buffer on linux and cause the
2458+
// wrong thing to get pasted.
24562459
d.input.selectionEnd = end;
2460+
d.input.selectionStart = start;
24572461
cm.state.fakedLastChar = true;
24582462
}
24592463
cm.state.pasteIncoming = true;

0 commit comments

Comments
 (0)