Allow OnTypeFormattingEditProvider edits to preserve cursor position #3745
Unanswered
jonatanklosko
asked this question in
Q&A
Replies: 2 comments
-
I think we mostly use
Kapture.2021-05-12.at.13.36.56.mp4 |
Beta Was this translation helpful? Give feedback.
0 replies
-
@alexdima thanks for the response! The problem with the suggested solution is that it would insert |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
monaco-editor version: 0.23.0
Browser: Chrome
OS: Linux (Ubuntu)
Playground code that reproduces the case
We are trying to have a
do/end
block autocompletion usingOnTypeFormattingEditProvider
. The above snippet provides a simplified version that demonstrates the issue we are facing.Here's a video of the behaviour:
do_end.mp4
Once the enter is pressed we end up in the following state:
Now if we insert
\nend
the cursor is moved, but we would like it to stay in place.Sidenote
We are able to overcome this problem if there is a line below, because we simply insert
end\n
in that line. However this doesn't work if we are in the last line already (and in our use case that's the primary scenario).Possible solutions
Ideally the text edit could have a property that leaves the cursor unchanged.
If there's a more proper way of implementing this, I'd be happy to hear!
Beta Was this translation helpful? Give feedback.
All reactions