Skip to content

Commit e117f28

Browse files
authoredNov 14, 2020
fix: persist cursor position on paste (#298)
1 parent dfbc071 commit e117f28

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

‎src/components/Editor.js

+6
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ function handleChange(cm, change) {
184184
case 'paste': {
185185
formatValue(cm);
186186
cm.onChange(cm.getValue(), { origin: change.origin });
187+
const text = change.text;
188+
const textLastPos = text.length - 1;
189+
cm.getDoc().setCursor({
190+
line: change.to.line + textLastPos,
191+
ch: text[textLastPos].length,
192+
});
187193
break;
188194
}
189195

0 commit comments

Comments
 (0)
Please sign in to comment.