Skip to content

Commit e565c4f

Browse files
damellislmihalkovic
authored andcommitted
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 a3ee226 commit e565c4f

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

app/src/processing/app/Editor.java

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import processing.app.syntax.ArduinoTokenMakerFactory;
4646
import processing.app.syntax.PdeKeywords;
4747
import processing.app.syntax.SketchTextArea;
48+
import processing.app.syntax.SketchTextAreaEditorKit;
4849
import processing.app.tools.DiscourseFormat;
4950
import processing.app.tools.MenuScroller;
5051
import processing.app.tools.Tool;
@@ -1872,28 +1873,8 @@ void handleCommentUncomment() {
18721873

18731874
private void handleIndentOutdent(boolean indent) {
18741875
if (indent) {
1875-
1876-
int caretPosition = textarea.getCaretPosition();
1877-
boolean noSelec = !textarea.isSelectionActive();
1878-
1879-
// if no selection, focus on first char.
1880-
if (noSelec) {
1881-
try {
1882-
int line = textarea.getCaretLineNumber();
1883-
int startOffset = textarea.getLineStartOffset(line);
1884-
textarea.setCaretPosition(startOffset);
1885-
} catch (BadLocationException e) {
1886-
}
1887-
}
1888-
1889-
// Insert Tab or Spaces..
1890-
Action action = textarea.getActionMap().get(RSyntaxTextAreaEditorKit.insertTabAction);
1876+
Action action = textarea.getActionMap().get(SketchTextAreaEditorKit.rtaIncreaseIndentAction);
18911877
action.actionPerformed(null);
1892-
1893-
if (noSelec) {
1894-
textarea.setCaretPosition(caretPosition);
1895-
}
1896-
18971878
} else {
18981879
Action action = textarea.getActionMap().get(RSyntaxTextAreaEditorKit.rstaDecreaseIndentAction);
18991880
action.actionPerformed(null);

0 commit comments

Comments
 (0)