Bug 501125 - Add Ctrl+D to delete a line in the commit message "editor"
Summary: Add Ctrl+D to delete a line in the commit message "editor"
Status: NEW
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted, usability
Depends on:
Blocks:
 
Reported: 2016-09-09 05:31 EDT by Lars Vogel CLA
Modified: 2019-07-14 15:45 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2016-09-09 05:31:57 EDT
One of my favorite shortcuts is Ctrl+D for deleting a line in the Java editor. Maybe you can use the same keybinding in the commit message editor to allow deleting lines?
Comment 1 Lars Vogel CLA 2019-06-11 04:19:06 EDT
Basically every day I try to delete a line in the staging view, especially if I use code completion to use an older commit message and have to remove the addition Change-ID line.

Would be nice to have Ctrl+D working.
Comment 2 Thomas Wolf CLA 2019-06-14 07:43:29 EDT
TL;DR: The clue is the quotes around "editor". Provide this in platform.

Long version:

This is an area where Eclipse really sucks. Many things that could be done on text _viewers_ are in eclipse (needlessly?) tied to text _editors_. This includes org.eclipse.ui.texteditor.DeleteLineAction.

StyledText does provide many actions out of the box (navigation, but also for instance delete next/previous word). However, StyledText used hardcoded key bindings.
The TextEditor framework provides its own actions for these, with customizeable key bindings. Change the key binding for "Delete Next Word" from the default to something else. It works in an editor, but the hard-coded default binding in StyledText also still works. In a plain TextViewer like the Commit Message "editor" in the staging view, only the default binding from StyledText works.

Other actions that are not available in StyledText (like DeleteLineAction, but also others) are provided by the TextEditor framework and won't work with ITextViewer or with a simple StyledText.

Xtext has built its own "embeddable editor", which is basically a duplication of the code for these ITextEditor actions. They have (minimally) modified them to work with ITextViewer and then provided their own context with key bindings matching the default bindings for text editors, which is activated/deactivated in a focus listener. See https://github.com/eclipse/xtext-eclipse/tree/master/org.eclipse.xtext.ui/src/org/eclipse/xtext/ui/editor/embedded .

Given that StyledText already does a lot of this it seems to me it should also provide the "Delete Line"/"Cut Line" operations. Ideally, the key bindings shouldn't be hard-coded either, but I can see that this might be difficult to overcome since SWT is at a lower level than the configurable bindings for the text editor actions.

If that is not doable, then I'd like to see this done in some other way in platform. 

Either change the architecture such that the basic text operations can be done in _any_ text viewer and don't depend on that viewer being in an ITextEditor. Then there'd be a context that would provide these key bindings, and anyone using a text viewer could just activate/deactivate that context in a focus listener, and you'd suddenly have all the common keyboard shortcuts in _all_ text viewers.

Or extract and generalize the efforts made in Xtext (removing xtext specifics and any Guice/Guava dependencies) and move into platform. If duplication is OK and one doesn't want to change the existing ITextEditor actions, then ideally as a separate feature or bundle with a very low minimum platform requirement (<= Neon.0, please). Then EGit could use that bundle and simply activate that context, and xtext could also use it and subclass to add whatever xtext specifics it needs.