Skip to content

Commit ac66a9c

Browse files
Change workaround for ctrl-slash handling in RSyntaxTextArea
Previously, there was a handler on the text area that consumed most KEY_TYPED events with control pressed. This was added a long time ago to fix a problem with ctrl-slash doing both the toggle comment action and inserting a /. Further investigation shows that with RSyntaxTextArea this problem is still present, but is caused by a weird binding on the slash key that Arduino is not even using. Removing that binding is a cleaner workaround for this problem, so this commit switches to that workaround. Ideally this would be fixed in RSyntaxTextArea, see bobbylight/RSyntaxTextArea#157
1 parent f068207 commit ac66a9c

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

app/src/processing/app/EditorListener.java

-8
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ public EditorListener(Editor editor) {
2222
private static final int CTRL_SHIFT = InputEvent.SHIFT_MASK | CTRL;
2323

2424
public void keyTyped(KeyEvent event) {
25-
char c = event.getKeyChar();
26-
27-
if ((event.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
28-
// The char is not control code when CTRL key pressed? It should be a shortcut.
29-
if (!Character.isISOControl(c)) {
30-
event.consume();
31-
}
32-
}
3325
}
3426

3527
@Override

app/src/processing/app/syntax/SketchTextAreaDefaultInputMap.java

+9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ public SketchTextAreaDefaultInputMap() {
2323

2424
remove(KeyStroke.getKeyStroke(KeyEvent.VK_K, defaultModifier));
2525

26+
// Remove a troublesome binding for the / key. By default, RSyntaxTextArea
27+
// binds the / KEY_TYPED event to insert a / and optionally complete any XML
28+
// tags. However, since this also triggeres on ctrl-slash, this means that
29+
// in addition to toggling comments on ctrl-slash, it also inserts a slash.
30+
// Since we don't need the XML completion feature anyway, just unbind it
31+
// here. A future version of RSyntaxTextArea might fix this, see
32+
// https://github.com/bobbylight/RSyntaxTextArea/issues/157.
33+
remove(KeyStroke.getKeyStroke('/'));
34+
2635
if (PreferencesData.getBoolean("editor.advanced")) {
2736
put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, alt), RTextAreaEditorKit.rtaLineDownAction);
2837
put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, alt), RTextAreaEditorKit.rtaLineUpAction);

0 commit comments

Comments
 (0)