فهرست منبع

[editor] Clear any error or success gutter markings once a statement is edited in Editor V2

Johan Ahlen 5 سال پیش
والد
کامیت
1807a72c28

+ 2 - 2
desktop/core/src/desktop/js/apps/notebook2/components/aceEditor/AceGutterHandler.ts

@@ -95,9 +95,9 @@ export default class AceGutterHandler implements Disposable {
 
           if (executable.isRunning()) {
             anchor.setGutterCss(EXECUTING_CSS);
-          } else if (executable.isSuccess()) {
+          } else if (!executable.edited && executable.isSuccess()) {
             anchor.setGutterCss(COMPLETED_CSS);
-          } else if (executable.isFailed()) {
+          } else if (!executable.edited && executable.isFailed()) {
             anchor.setGutterCss(FAILED_CSS);
             if (executable.logs && executable.logs.errors.length) {
               const error = executable.logs.errors[0];

+ 2 - 0
desktop/core/src/desktop/js/apps/notebook2/execution/executable.ts

@@ -91,6 +91,7 @@ export default abstract class Executable {
   nextExecutable?: Executable;
   observerState: { [key: string]: unknown } = {};
   lost = false;
+  edited = false;
 
   protected constructor(options: { executor: Executor }) {
     this.executor = options.executor;
@@ -190,6 +191,7 @@ export default abstract class Executable {
     if (!this.isReady()) {
       return;
     }
+    this.edited = false;
     this.executeStarted = Date.now();
 
     this.setStatus(EXECUTION_STATUS.running);

+ 7 - 4
desktop/core/src/desktop/js/apps/notebook2/execution/utils.ts

@@ -31,12 +31,13 @@ export const syncSqlExecutables = (
   executor: Executor,
   statementDetails: StatementDetails
 ): SyncSqlExecutablesResult => {
-  const allNewStatements = statementDetails.precedingStatements.concat(
+  const allNewStatements = [
+    ...statementDetails.precedingStatements,
     statementDetails.activeStatement,
-    statementDetails.followingStatements
-  );
+    ...statementDetails.followingStatements
+  ];
 
-  const existingExecutables: (Executable | undefined)[] = executor.executables.concat();
+  const existingExecutables: (Executable | undefined)[] = [...executor.executables];
 
   const result = {
     all: <SqlExecutable[]>[],
@@ -65,6 +66,7 @@ export const syncSqlExecutables = (
       executable.database = activeDatabase;
       executable.parsedStatement = parsedStatement;
       if (edited) {
+        executable.edited = true;
         result.edited.push(executable);
       }
     } else {
@@ -73,6 +75,7 @@ export const syncSqlExecutables = (
         database: activeDatabase,
         executor: executor
       });
+      executable.edited = true;
     }
     if (parsedStatement === statementDetails.activeStatement) {
       activeStatementIndex = index;