Skip to content

Commit 3fc7980

Browse files
committed
PDEX: Remove some unnecessary calls from rename
1 parent 76fef4b commit 3fc7980

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

java/src/processing/mode/java/pdex/PDEX.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,10 @@ public class PDEX {
9393
private Rename rename;
9494
private DebugTree debugTree;
9595

96-
private JavaEditor editor;
9796
private PreprocessingService pps;
9897

9998

10099
public PDEX(JavaEditor editor, PreprocessingService pps) {
101-
this.editor = editor;
102100
this.pps = pps;
103101

104102
this.enabled = !editor.hasJavaTabs();
@@ -803,8 +801,6 @@ void rename(PreprocessedSketch ps, IBinding binding, String newName) {
803801

804802
editor.startCompoundEdit();
805803

806-
int currentTabIndex = sketch.getCurrentCodeIndex();
807-
final int currentOffset = editor.getCaretOffset();
808804
mappedNodes.entrySet().forEach(entry -> {
809805
int tabIndex = entry.getKey();
810806
SketchCode sketchCode = sketch.getCode(tabIndex);
@@ -833,9 +829,15 @@ void rename(PreprocessedSketch ps, IBinding binding, String newName) {
833829
sketchCode.setProgram(document.getText(0, document.getLength()));
834830
} catch (BadLocationException e) { /* Whatever */ }
835831
sketchCode.setModified(true);
836-
editor.repaintHeader();
837832
});
838833

834+
editor.stopCompoundEdit();
835+
836+
editor.repaintHeader();
837+
838+
int currentTabIndex = sketch.getCurrentCodeIndex();
839+
final int currentOffset = editor.getCaretOffset();
840+
839841
int precedingIntervals =
840842
(int) mappedNodes.getOrDefault(currentTabIndex, Collections.emptyList())
841843
.stream()
@@ -844,10 +846,8 @@ void rename(PreprocessedSketch ps, IBinding binding, String newName) {
844846
int intervalLengthDiff = newName.length() - binding.getName().length();
845847
int offsetDiff = precedingIntervals * intervalLengthDiff;
846848

847-
sketch.setCurrentCode(currentTabIndex);
848849
editor.getTextArea().setCaretPosition(currentOffset + offsetDiff);
849850

850-
editor.stopCompoundEdit();
851851
}
852852

853853

0 commit comments

Comments
 (0)