Typing open bracket should surround the selected text element with brackets
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?
@vogella: Sorry I didn't get it. What is a "text element" and was is the "selected work"?
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)
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).
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
Awesome, thanks @lathapatil
Also thanks @mickaelistria. I hope at some point the base JDT editor is changed to the generic code editor to benefit from such developments.
The feature is now always active, unless overridden in code.
Shouldn't this feature be made optional using a preference page and/or coupled to the 'Smart Insert Mode'?
Optional features are hard be discover for users. Why do you think it should not be active by default?
The way I read it, this is suggesting for a way to control the behavior with no comment about what the default should be...
Yes, enabled by default is is fine, but I think there should be a way to disable this functionality, similar to Java-specific preferences: