Skip to content

Commit 4bf5900

Browse files
authored
Merge pull request #38 from aldinezi/expand_insert
Check for selection and insert character over selection.
2 parents fdde574 + 7132f6a commit 4bf5900

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/keyboard.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,11 @@
177177
},
178178
179179
insertChar(caret, text, ch) {
180-
text = text.substr(0, caret.start) + ch.toString() + text.substr(caret.start);
180+
if (caret.start < caret.end) {
181+
text = text.substring(0, caret.start) + ch.toString() + text.substring(caret.end);
182+
} else {
183+
text = text.substr(0, caret.start) + ch.toString() + text.substr(caret.start);
184+
}
181185
caret.start += ch.length;
182186
caret.end = caret.start;
183187
return text;

0 commit comments

Comments
 (0)