1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 21:57:59 +01:00

Fix <S-Insert> when newlines are involved.

This commit is contained in:
Kris Maglione
2010-12-31 16:12:05 -05:00
parent edd65b0abe
commit 9f7ef8634c
5 changed files with 6 additions and 8 deletions

View File

@@ -45,7 +45,7 @@ var Editor = Module("editor", {
let start = elem.selectionStart; // caret position
let end = elem.selectionEnd;
elem.value = elem.value.substring(0, start) + text + elem.value.substring(end);
elem.selectionStart = start + (toStart ? 0 : text.length);
elem.selectionStart = Math.min(start + (toStart ? 0 : text.length), elem.value.length);
elem.selectionEnd = elem.selectionStart;
elem.scrollTop = top;