File tree 1 file changed +6
-4
lines changed
app/src/cc/arduino/packages/formatter/clangformat
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 45
45
46
46
import processing .app .Base ;
47
47
import processing .app .Editor ;
48
+ import processing .app .EditorTab ;
48
49
import processing .app .helpers .ProcessUtils ;
49
50
50
51
public class ClangFormat implements Runnable {
@@ -59,16 +60,17 @@ public ClangFormat(Editor editor) {
59
60
60
61
@ Override
61
62
public void run () {
62
- String originalText = editor .getCurrentTab ().getText ();
63
- int cursorOffset = editor .getCurrentTab ().getTextArea ().getCaretPosition ();
63
+ EditorTab tab = editor .getCurrentTab ();
64
+ String originalText = tab .getText ();
65
+ int cursorOffset = tab .getTextArea ().getCaretPosition ();
64
66
try {
65
67
FormatResult result = runClangFormatOn (originalText , cursorOffset );
66
68
if (result .FormattedText .equals (originalText )) {
67
69
editor .statusNotice (tr ("No changes necessary for Auto Format." ));
68
70
return ;
69
71
}
70
- editor . getCurrentTab () .setText (result .FormattedText );
71
- editor . getCurrentTab () .getTextArea ().setCaretPosition (result .Cursor );
72
+ tab .setText (result .FormattedText );
73
+ tab .getTextArea ().setCaretPosition (result .Cursor );
72
74
editor .statusNotice (tr ("Auto Format finished." ));
73
75
} catch (IOException | InterruptedException e ) {
74
76
editor .statusError ("Auto format error: " + e .getMessage ());
You can’t perform that action at this time.
0 commit comments