Skip to content

Commit 07903b8

Browse files
committed
Use new IncreaseIndentAction for Edit > Increase Indent.
This simplifies the code a bit and fixes a small bug that would cause the cursor to fail to move with the text being indented.
1 parent 05be148 commit 07903b8

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

app/src/processing/app/Editor.java

+2-21
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import processing.app.syntax.ArduinoTokenMakerFactory;
4545
import processing.app.syntax.PdeKeywords;
4646
import processing.app.syntax.SketchTextArea;
47+
import processing.app.syntax.SketchTextAreaEditorKit;
4748
import processing.app.tools.DiscourseFormat;
4849
import processing.app.tools.MenuScroller;
4950
import processing.app.tools.Tool;
@@ -1866,28 +1867,8 @@ void handleCommentUncomment() {
18661867

18671868
private void handleIndentOutdent(boolean indent) {
18681869
if (indent) {
1869-
1870-
int caretPosition = textarea.getCaretPosition();
1871-
boolean noSelec = !textarea.isSelectionActive();
1872-
1873-
// if no selection, focus on first char.
1874-
if (noSelec) {
1875-
try {
1876-
int line = textarea.getCaretLineNumber();
1877-
int startOffset = textarea.getLineStartOffset(line);
1878-
textarea.setCaretPosition(startOffset);
1879-
} catch (BadLocationException e) {
1880-
}
1881-
}
1882-
1883-
// Insert Tab or Spaces..
1884-
Action action = textarea.getActionMap().get(RSyntaxTextAreaEditorKit.insertTabAction);
1870+
Action action = textarea.getActionMap().get(SketchTextAreaEditorKit.rtaIncreaseIndentAction);
18851871
action.actionPerformed(null);
1886-
1887-
if (noSelec) {
1888-
textarea.setCaretPosition(caretPosition);
1889-
}
1890-
18911872
} else {
18921873
Action action = textarea.getActionMap().get(RSyntaxTextAreaEditorKit.rstaDecreaseIndentAction);
18931874
action.actionPerformed(null);

0 commit comments

Comments
 (0)