A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
sql linter: add listener to set focus state and parse only when focused (#6591)
Shahmir Varqha9d1cfcab4170
diff --git a/frontend/src/core/codemirror/language/languages/sql/sql.ts b/frontend/src/core/codemirror/language/languages/sql/sql.tsindex 4b31e1433f..2bc1d9c5e0 100644--- a/frontend/src/core/codemirror/language/languages/sql/sql.ts+++ b/frontend/src/core/codemirror/language/languages/sql/sql.ts@@ -279,6 +279,11 @@ export class SQLLanguageAdaptertheme: defaultSqlHoverTheme(theme),},}),+ EditorView.updateListener.of((update) => {+ if (update.focusChanged) {+ parser.setFocusState(update.view.hasFocus);+ }+ }),);}@@ -293,6 +298,11 @@ export class SQLLanguageAdapterclass CustomSqlParser extends NodeSqlParser {private validationTimeout: number | null = null;private readonly VALIDATION_DELAY_MS = 300; // Wait 300ms after user stops typing+ private isFocused = false; // Only validate if the editor is focused++ setFocusState(focused: boolean) {+ this.isFocused = focused;+ }private async validateWithDelay(sql: string,@@ -307,6 +317,12 @@ class CustomSqlParser extends NodeSqlParser {// Set up a new request to be called after the delayreturn new Promise((resolve) => {this.validationTimeout = window.setTimeout(async () => {+ // Only validate if the editor is still focused+ if (!this.isFocused) {+ resolve([]);+ return;+ }+try {const sqlMode = getSQLMode();const result = await validateSQL(sql, engine, dialect, sqlMode);@@ -330,6 +346,11 @@ class CustomSqlParser extends NodeSqlParser {): Promise<SqlParseError[]> {const metadata = getSQLMetadata(opts.state);+ // Only validate if the editor is focused+ if (!this.isFocused) {+ return [];+ }+// Only perform custom validation for DuckDBif (!INTERNAL_SQL_ENGINES.has(metadata.engine)) {return super.validateSql(sql, opts);