eclipse-platform / eclipse.platform.ui

Eclipse Platform
https://projects.eclipse.org/projects/eclipse.platform
Eclipse Public License 2.0
81 stars 182 forks source link

Typing open bracket should surround the selected text element with brackets #865

Open vogella opened 1 year ago

vogella commented 1 year ago

If I select an text element and type an opening bracket, e.g. "(" VScode the selected work is surrounded by brackets, if I do the same in Eclipse the work is deleted.

I think the VScode behavior is much nicer and noticed this difference while testing @mickaelistria LS-JDT integration for Eclipse.

Would be also adjust the behavior in Eclipse? If yes, which editor would be good to implement this? Text editor or generic editor?

BeckerWdf commented 1 year ago

@vogella: Sorry I didn't get it. What is a "text element" and was is the "selected work"?

vogella commented 1 year ago

Type WORD in an editor Double-click on WORD to select it Now type "(" -> WORD gets deleted in Eclipse

Do the same in code, the result is: -> (WORD)

mickaelistria commented 7 months ago

Note that since we already have in most editors some strategy to auto-insert a closing brackets, this request is most likely just an extension of the existing strategies to tweak the handling of insertion with a non-empty selection. For the generic editor (and TM4E that already provide all the matching bracket smartness for a given language), it's mostly a matter of updating the org.eclipse.tm4e.languageconfiguration.internal.LanguageConfigurationAutoEditStrategy, for JDT it looks like it's a matter of changing CompilationUnitEditor.verifyKey() to add the overridden content between buffer.append(character) and buffer.append(closingCharacter).

mickaelistria commented 7 months ago

FWIW, this just got implemented in TM4E (so it would serve many editors already, but not default JDT one): https://github.com/eclipse/tm4e/commit/501ede88852ec05ac9f0414c75783effa33cb1e9