From 07903b8585a6af8f28fea7b13500bc0ca5bbad20 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Mon, 21 Dec 2015 16:42:40 -0800 Subject: [PATCH] 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. --- app/src/processing/app/Editor.java | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 9a30f5250..3fe661895 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -44,6 +44,7 @@ import processing.app.legacy.PApplet; import processing.app.syntax.ArduinoTokenMakerFactory; import processing.app.syntax.PdeKeywords; import processing.app.syntax.SketchTextArea; +import processing.app.syntax.SketchTextAreaEditorKit; import processing.app.tools.DiscourseFormat; import processing.app.tools.MenuScroller; import processing.app.tools.Tool; @@ -1866,28 +1867,8 @@ public class Editor extends JFrame implements RunnerListener { private void handleIndentOutdent(boolean indent) { if (indent) { - - int caretPosition = textarea.getCaretPosition(); - boolean noSelec = !textarea.isSelectionActive(); - - // if no selection, focus on first char. - if (noSelec) { - try { - int line = textarea.getCaretLineNumber(); - int startOffset = textarea.getLineStartOffset(line); - textarea.setCaretPosition(startOffset); - } catch (BadLocationException e) { - } - } - - // Insert Tab or Spaces.. - Action action = textarea.getActionMap().get(RSyntaxTextAreaEditorKit.insertTabAction); + Action action = textarea.getActionMap().get(SketchTextAreaEditorKit.rtaIncreaseIndentAction); action.actionPerformed(null); - - if (noSelec) { - textarea.setCaretPosition(caretPosition); - } - } else { Action action = textarea.getActionMap().get(RSyntaxTextAreaEditorKit.rstaDecreaseIndentAction); action.actionPerformed(null);