File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
app/src/cc/arduino/packages/formatter/clangformat Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 4545
4646import processing .app .Base ;
4747import processing .app .Editor ;
48+ import processing .app .EditorTab ;
4849import processing .app .helpers .ProcessUtils ;
4950
5051public class ClangFormat implements Runnable {
@@ -59,16 +60,17 @@ public ClangFormat(Editor editor) {
5960
6061 @ Override
6162 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 ();
6466 try {
6567 FormatResult result = runClangFormatOn (originalText , cursorOffset );
6668 if (result .FormattedText .equals (originalText )) {
6769 editor .statusNotice (tr ("No changes necessary for Auto Format." ));
6870 return ;
6971 }
70- editor . getCurrentTab () .setText (result .FormattedText );
71- editor . getCurrentTab () .getTextArea ().setCaretPosition (result .Cursor );
72+ tab .setText (result .FormattedText );
73+ tab .getTextArea ().setCaretPosition (result .Cursor );
7274 editor .statusNotice (tr ("Auto Format finished." ));
7375 } catch (IOException | InterruptedException e ) {
7476 editor .statusError ("Auto format error: " + e .getMessage ());
You can’t perform that action at this time.
0 commit comments