From 742627abcab8314dcabed2ce8ae6d347eaaf5512 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 15 Nov 2022 09:36:27 +0100 Subject: [PATCH] [sql-hint addon] Fix retrieving of parser config --- addon/hint/sql-hint.js | 10 ++++++---- mode/sql/sql.js | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/addon/hint/sql-hint.js b/addon/hint/sql-hint.js index e01f502635..61faec0bc0 100644 --- a/addon/hint/sql-hint.js +++ b/addon/hint/sql-hint.js @@ -23,14 +23,16 @@ function isArray(val) { return Object.prototype.toString.call(val) == "[object Array]" } + function getModeConf(editor) { + return editor.getModeAt(editor.getCursor()).config || CodeMirror.resolveMode("text/x-sql") + } + function getKeywords(editor) { - return editor.getModeAt(editor.getCursor()).keywords || CodeMirror.resolveMode("text/x-sql").keywords; + return getModeConf(editor).keywords || [] } function getIdentifierQuote(editor) { - return editor.getModeAt(editor.getCursor()).identifierQuote || - CodeMirror.resolveMode("text/x-sql").identifierQuote || - "`"; + return getModeConf(editor).identifierQuote || "`"; } function getText(item) { diff --git a/mode/sql/sql.js b/mode/sql/sql.js index 105b22ffb9..fedf6cd77c 100644 --- a/mode/sql/sql.js +++ b/mode/sql/sql.js @@ -207,7 +207,8 @@ CodeMirror.defineMode("sql", function(config, parserConfig) { blockCommentStart: "/*", blockCommentEnd: "*/", lineComment: support.commentSlashSlash ? "//" : support.commentHash ? "#" : "--", - closeBrackets: "()[]{}''\"\"``" + closeBrackets: "()[]{}''\"\"``", + config: parserConfig }; });