Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

How to set cursor position after inserting text #184

Open
ashitvora-zz opened this issue Jan 23, 2018 · 0 comments
Open

How to set cursor position after inserting text #184

ashitvora-zz opened this issue Jan 23, 2018 · 0 comments

Comments

@ashitvora-zz
Copy link

ashitvora-zz commented Jan 23, 2018

I have a use case where a user clicks a button to insert text at the current cursor position.
But after the text is inserted using session.insert(cursorPosition, textToAdd), the position of cursor moves to the very first character.

I tried placing the cursor after the recently added text by using the following approach but it didn't work.

renderer.scrollCursorIntoView({
    row: cursorPosition.row,
    column: cursorPosition.column + param.length
}, 0.5)

Any idea how to achieve this?

Basically, if a user keeps clicking the button, text to should be added at the current cursor position and then after the recently added text unless user places the cursor somewhere else explicitly.

Here's the JS Fiddle for the reference - https://jsfiddle.net/ashitvora/q27ebeeq/34/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant