[RFE] Add smart caret positioning to org.eclipse.ui.texteditor.AbstractTextEditor #1825
Open
2 tasks done
Labels
enhancement
New feature or request
Suggestion
JDT and CDT offer a so called "smart caret positioning" in identifiers. I suggest to add that feature to
org.eclipse.ui.texteditor.AbstractTextEditor
so that most editors could use that feature, too. For example, the CDT LSP editor for C/C++ code (this one is based onorg.eclipse.ui.internal.genericeditor.ExtensionBasedTextEditor
) needs the same feature and likely many other editors, too.Smart Caret Positioning
In Java (JDT) and in C/C++ (CDT), the option "smart caret positioning" activates navigation in text editors via Ctrl + left / right to select the next / previous sub-word or to extend the current selection with Ctrl + Shift + left / right by one sub-word. By sub-word the implementation means the next word in an identifier that (potentially) uses camel case.
"Smart caret positioning" means for an identifier
someInterestingIdentifier
with the caret placed aftersome
, i.e.some^InterestingIdentifier
that Ctrl + right would place the caret aftersomeInteresting
, i.e.someInteresting^Identifier
. Without "smart caret positioning" the caret would jump to the end of the identifier. The same applies for extending the current selection, e.g. having the selection some , i.e.^some^InterestingIdentifier
and hitting Ctrl + Shift + right extends it to someInteresting, i.e.^someInteresting^Identifier
.Feature Request
JDT offers the following setting in the preferences (Java -> Editor):
I hope, we can generalize that feature so that it could be used for all editors extending the
AbstractTextEditor
class. Maybe the setting "smart caret positioning" could be switched off by default and could be activated by certain editors. Of course, editors could only use that feature if they have identifiers in their language.In general, "smart caret positioning" could be extended to consider
someInterestingIdentifier
)SomeInterestingIdentifier
)some_interesting_identifier
)some-Interesting-identifier
)It could be useful being able to switch support for these cases on and off, depending on the use case (language) in a custom editor.
Like in JDT and CDT, it should be possible to turn "smart caret positioning" on or off using common preferences for text editor (preferences in General -> Editors -> Text Editors) or for a special text editor (in custom preference pages).
Discussion
Is there any chance to implement that feature for
AbstractTextEditor
? How could that be done? I guess, theAbstractTextEditor
would have to know if the concrete editor's language has identifiers and would need access to the identifiers. JDT and CDT use a customjava.text.BreakIterator
to implement that feature.If adding that feature to
AbstractTextEditor
is not an option, I think, I would have to somehow adapt LSP4E or CDT LSP to add that feature. But that would probably result in code duplicated from JDT as it has been done for CDT.Community
The text was updated successfully, but these errors were encountered: