Cursor jumping problem

After some really great updates in the latest version it seemed to be doing everything I need at present.

However, I suddenly started experiencing the cursor jumping problem described here Cursor randomly jumps to beginning of line #437 and here (now closed) Cursor jumping after press return #476.

I cannot remember having seen it before but I think it started when I installed rc9.2. I only use the zip installs, so none of the installed program files gets overwritten. It is however such an irritating problem, basically making the editor unusable, that I could not have missed it before.

I went back to "arduino-ide_nightly-20220721" (the oldest I have) but that now also exhibits the same behaviour.

I am at a loss. As it is now so I cannot use it and will have to go back to ver 1.

Could it be an unintentional setting change, now stored, causing it? If so, where? I tried deleting the "Arduino IDE" and "arduino-ide" folders (and a few more) but cannot get rid of it. How do I clear all possible saved setting in version 2? Deleting the previous folders does not clear everything since the last used sketch is still remembered on opening.

Any help?

These are the folders of interest:

Configuration folder

Windows

%HOMEPATH%\.arduinoIDE\ 

(e.g., C:\Users\<username>\.arduinoIDE\)

Linux

~/.arduinoIDE/ 

macOS

~/.arduinoIDE 

User Data Folder

Windows

%APPDATA%\arduino-ide\ 

(e.g., C:\Users\<user name>\AppData\Roaming\arduino-ide\)

Linux

~/.config/arduino-ide/ 

macOS

~/Library/Application Support/arduino-ide/ 

I have also noticed that on Windows (it doesn't occur for me on Linux). I never managed to figure out where that information is stored (maybe it is in the Windows registry?).

I have never had a situation where simply deleting the folders above (perhaps in addition to the sketchbook and data folder in other cases where the presence of existing sketches, libraries, boards platforms, indexes, etc. might be significant) did not adequately simulate a fresh install.

I was just looking at my notes on the subject and found a link to some interesting related information from one of the primary developers of the Arduino IDE 2.x:

It might be that it is equivalent to manually deleting one of the folders I listed above, but in case you want to give it a try I'll provide more detailed instructions (make sure to check the screencast at the link above if they are unclear):

  1. Open the "Command Palette" by pressing the Ctrl+Shift+P (Command+Shift+P for macOS users) keyboard shortcut.
  2. Select the "Toggle Developer Tools" command from the menu.
  3. Press Enter
    The developer tools panel (referred to as "DevTools" in the link I shared above) will now open in a side panel of the Arduino IDE window.
  4. Select the "Console" tab from the developer tools panel.
  5. At the bottom of the Console" tab, you will see a terminal prompt (>). Click on it.
  6. Type the following command at the terminal prompt:
    localStorage.clear() 
  7. Press Enter
    You will see it responds "undefined". This was also in the developer's screencast so it is not a sign that something went wrong.
  8. Reload the window by pressing the Ctrl+R (Command+R for macOS users) keyboard shortcut.

@ptillisch Thanks for the reply.

I am on Windows 10. So I removed the above Configuration folder, %HOMEPATH%\.arduinoIDE\ and all the User Data folders, %APPDATA%\arduino-ide\ as well as %APPDATA%\Arduino IDE\. I also did the above "localStorage.clear()". The cursor jump problem persists.

I next went to a different Windows installation (on the same PC) and found I have installed earlier nightlies there: arduino-ide_nightly-20210904 does not show the same problem but arduino-ide_nightly-20220117 does.

Next I thought a new graphics card I have installed recently might contribute. So I removed the card and went back to the onboard Intel graphic adaptor. Problem still there.

I do not know why the problem now started but it basically stopped me from being able to use IDE 2. What changed and why do I now have the cursor jumping problem and other users not?

It might be possible to identify this by doing a "bisection" of the problem.

You already have a version of the IDE with the "bad" behavior, and a version of the IDE with the "good" behavior. This indicates that some change made between those two versions caused the regression.

The large range between the "good' and "bad" versions does not allow that specific change to be identified. In order to do so, the range must be reduced. If it can be reduced to a single change, there is a good chance that change was the cause. Unfortunately, it is not always quite so straightforward as that because some of these bugs are pseudo-intermittent in nature, where they are dependent on environmental factors or specific timings. This means something that appears to be a "good" version may actually be a "bad" version where you just didn't happen to provide the required conditions while testing. Even so, bisection often does provide definitive results.

You could narrow the range down a bit more by checking the release versions that fall inside that range between your current "good" and "bad". These are convenient because the packaged application is available for download. The download links are under the "Assets" section of each release page linked below.

Once you get through that rough bisection, it becomes a bit more tricky to go more granular because prebuild packages are not available at a finer scale (we do produce them, but GitHub expires them after 90 days). It actually is not too difficult to run the IDE from source, following the instructions here:

https://github.com/arduino/arduino-ide/blob/main/BUILDING.md#build-from-source

The good news about this is you are now able to use the useful git bisect command to facilitate the bisection down to a single commit. There is one caveat, which is that the performance of the IDE is lower when running from source. In the case of a bug that is dependent on the timing of different processes, this difference can mean that the testing results do not match those you get when using the optimized packaged version of the IDE. It is also possible to build the packages from source. You can see the commands here:

https://github.com/arduino/arduino-ide/blob/main/.github/workflows/build.yml#L101-L102

yarn --cwd ./electron/packager/ yarn --cwd ./electron/packager/ package 

After that completes, you will find a ready to run installation in the subfolder of the repository here:

electron/build/dist/win-unpacked/Arduino IDE.exe 

OK. I did some checking through the releases.

My oldest nightly is a later version of Beta.11. That one does not exhibit the cursor jump at all. An occasional funny but not really a problem.

Beta.12 does exhibit the problem. However, after pressing enter at the end of a line the cursor goes to the correct position on the new line, lining up with the start of the previous line, but it takes about 6 seconds for it to jump to the start of the new line.

When entering or editing code I would not have noticed the jump. It is not normal, for me at least, to start a new line and wait that long before typing. If the enter was merely to add an empty line, it does not matter if the cursor jumps to the start.

This ~6 second delay stays with the releases right up to RC6. With RC7 the delay changed to about 1 second and stayed with all the releases. That is what I now also have in the latest nightly.

If that delay can be changed all would be OK.

After trying all sorts of things I came up with a working solution (and maybe an indication of a bug).

If I disable Trim Auto Whitespace in the advanced Editor settings everything works as I would expect. The current default setting is enabled (box ticked).

Trim Auto Whitespace Remove trailing auto inserted whitespace. 

When hitting enter at the end of a line, it seems the editor considers the inserted spaces, to align the new line start with the previous line, as trailing whitespace belonging to the previous line and removes them - moving the cursor to the start of the line (they are actually not completely removed and do strange things).

Thanks @Willem43! Excellent find.

I discovered that I am able to reproduce the issue on one of my machines (though not on my primary machine). I did some further investigation and made a report on GitHub

https://github.com/arduino/arduino-ide/issues/437#issuecomment-1221379270

Unfortunately, I did not get too far, but at least I think it is progress.

My discovery that the issue appears to be coming from the underlying framework rather than Arduino's own bespoke code is not such great news because it means that either we must wait for the problem to be fixed upstream, be released there, and then finally pulled into the Arduino IDE by bumping the dependency (which is a long process), or else perhaps to patch the upstream bug in the Arduino IDE code base (which tends to be challenging, hacky, and hard to maintain).

@ptillisch. Thanks for the follow-up. I read your github report, great detective work.

I can happily use the IDE with editor.trimAutoWhitespace set to false. I will keep an eye on this should/when it be resolved in future.

1 Like

Hello,

I think I have the same problem here.
At enter in the middle of the program, the cursor jumps back to the beginning of the line. When I give a tab it jumps to the next line. Very tricky.
Where can I change that "editor.trimAutoWhitespace" setting?

Hi @gerriew. Here are the instructions for the workaround to this bug:

  1. Open the "Command Palette" via the Ctrl+Shift+P (Command+Shift+P for macOS users) keyboard shortcut.
  2. Select the "Preferences: Open Settings (UI)" command.
  3. A "Preferences" tab will now open in the Arduino IDE main panel. In the "Search Settings" field, type editor.trimAutoWhitespace
  4. Uncheck the checkbox next to the " Remove trailing auto inserted whitespace." setting.
  5. Click the X icon on the "Preferences" tab.

Please let me know if you have any questions or problems while following those instructions.

Hello ptillisch,

Thanks for the info. I changed the setting and it works fine now. The cursor now does not jump back and forth.
Thank you

You are welcome. I'm glad it is working now.

Regards,
Per

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.