antlr / intellij-plugin-v4

An IntelliJ plugin for ANTLR v4
https://plugins.jetbrains.com/plugin/7358-antlr-v4
BSD 3-Clause "New" or "Revised" License
462 stars 103 forks source link

Cursor moves to last non-space character when switching IntelliJ file or window #606

Closed blueglyph closed 1 year ago

blueglyph commented 1 year ago

Description

When this plugin is active, the editor behaves incorrectly and shows the bug reported here (link):

In the editor, when the cursor has space characters to its left (typically indented on a new line), if the user

  • switches to another file then back
  • switches to another IntelliJ window then back

then the cursor moves back after the last non-space or the start of the line.

It doesn't occur when the user switches to another process then back.

I tested several times by disabling and enabling this plugin (and others), and the problem only occurs when this plugin is active (and then it occurs all the time). I never noticed that in earlier versions of the plugin.

This is quite annoying, I'm currently writing tests and code that are in separate files, and this is really happening all the time. I'll disable the plugin for now.

Environment

IntelliJ IDEA 2022.3.1 (Ultimate Edition) Windows 10 10.0 Non-Bundled Plugins: org.antlr.intellij.plugin (1.19.3-3) org.rust.lang (0.4.186.5143-223) com.intellij.nativeDebug (223.8214.16) org.asciidoctor.intellij.asciidoc (0.38.4)

Kotlin: 223-1.7.21-release-272-IJ8214.52

bjansen commented 1 year ago

Is the cursor moving, or is IntelliJ trimming extra whitespace at the end of the line? What's your configuration in Settings > Editor > General > On Save ?

image
blueglyph commented 1 year ago

It's only trimming if the line is not empty, so if I add a few spaces at the end of an existing line and switch back & forth, the spaces are removed. When the plugin is disabled, those spaces remain (and the cursor remains there too).

If it's a few line, the spaces are still there, so if I jump to end of the line my cursor moves back to where it was. When the plugin is disabled, those spaces remain (and the cursor remains there too).

Are you implying that you cannot reproduce the bug?

image

bjansen commented 1 year ago

I haven't tried to reproduce yet, I just find it very odd that the plugin is affecting other file types.

blueglyph commented 1 year ago

I found that very strange too, especially in projects that don't even have files related to the plugin (pure Rust or Kotlin projects).

blueglyph commented 1 year ago

I got the problem with the plugin disabled, so I reported that on IntelliJ's bug tracker.

I'm closing this PR.