eclipse-tm4e / tm4e

TextMate support in Eclipse IDE
https://projects.eclipse.org/projects/technology.tm4e
Eclipse Public License 2.0
94 stars 57 forks source link

OnEnterRules broken for indentOutdent? #718

Closed ahmedneilhussain closed 9 months ago

ahmedneilhussain commented 9 months ago

Hi @sebthom I think https://github.com/eclipse/tm4e/commit/2e1769ff4d3ce2b891b134af655f88468cbc73e7 might have broken the indentOutdent behaviour for on enter.

I've just been reevaluating tm4e (my company uses lsp4e for our language, but we have been using our own customisations to the generic editor for syntax highlighting and auto-edit, and we'd like to jettison this handwritten code if possible!). I tried the very latest version with our code and found the auto-indentation behaviour was a bit unexpected, which I initially thought was down to my misconfiguring it, then I dug a bit further using wild web developer's typescript support as a test case.

With typescript and a slightly older tm4e, given a snippet

  if (true) {}

and the cursor between the two braces, I get

  if (true) {
    <-- cursor here
  }

as I'd like. With the latest tm4e I get

  if (true) {
    <-- correctly indented to here
  } <-- but cursor just to left of the parenthesis

I think when you rewrote the switch at https://github.com/eclipse/tm4e/blob/093cd523f301609f916c34bc9392a771eec29412/org.eclipse.tm4e.languageconfiguration/src/main/java/org/eclipse/tm4e/languageconfiguration/internal/LanguageConfigurationAutoEditStrategy.java#L224 to use java-17 style yield you might have inadvertently changed the logic for determining the new caret position. It now assumes the caret should go after the inserted text in all cases, but that's not how it was before for indentOutdent as you can see here: https://github.com/eclipse/tm4e/blob/222653b2210649c4752f72967d57c72bbc964178/org.eclipse.tm4e.languageconfiguration/src/main/java/org/eclipse/tm4e/languageconfiguration/internal/LanguageConfigurationAutoEditStrategy.java#L213

It'd be the gentlemanly thing to just submit a patch, but I've only been asked to spend a day or so reinvestigating the plugin so I haven't really had much of a look at the code let alone the testing/coding standards - apologies...!

Cheers, Ahmed

sebthom commented 9 months ago

Fixed in 0.10.2. Thanks for reporting!