question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typing 'too fast' causes cursor to jump to end of monaco editor

See original GitHub issue

Easiest way for me to reproduce this is to load up a scratch and then hold down a key, e.g. / to add a bunch of slashes. After ~3 the cursor jumps to the bottom of the editor.

I feel like this has something to do with the setState value/set being shared/reused with the editor, i.e. the value of the editor is set via setCCode. If the call to setCCode is removed, then the problem disappears - however the value of cCode is not set so the value being past to the compiler, so it’s not a solution.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mkstcommented, Aug 11, 2021

@zbanks found the fix, decouple value and use defaultValue instead:

--- a/frontend/src/scratch/Editor.jsx
+++ b/frontend/src/scratch/Editor.jsx
@@ -41,7 +41,7 @@ export default function Editor({ forceLoading, value, onChange, padding }) {
                     wordWrap: "on",
                     padding: padding ? { top: 30, bottom: 30 } : {},
                 }}
-                value={value}
+                defaultValue={value}
                 onChange={onChange}
             />
         </div>
1reaction
ethteckcommented, Aug 11, 2021

To update, this happens when you just type two characters in rapid succession. You can reproduce it by just pressing two keys at the same time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When I set the value, the cursor moves to the document header.
create a editor with some default values,then i call monacoInstance.setValue('some text');the cursor always move to the head of the first ...
Read more >
Cursor jumps or moves randomly while typing in Windows 10
If you find that your mouse cursor jumps or moves on its own, automatically, randomly while typing in Windows laptop or computer, ...
Read more >
Cursor jumps while typing : How to fix - YouTube
How to Fix Cursor Pointer Jumping While Typing : If your mouse cursor jumps while you type, you can follow the steps demonstrated...
Read more >
January 2022 (version 1.64) - Visual Studio Code
If the Side Panel is not open, just like the bottom Panel, dragging a view to the edge of the editor area, will...
Read more >
The Monaco Code Editor | Hacker News
Does anyone know on a technical level why the Monaco editor feels so much faster than the Atom editor? Is there any mechanism...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found