Closed yinyihui closed 1 year ago
As long time no relpy, I tried myself to change the source code and it works well. Just add the code after the popup checker, it can works correctly.
Origin: https://github.com/codemirror/codemirror5/blob/7f488eb5c12d71ea7ea75e286b7b9c029453a298/addon/hint/sql-hint.js#L275
if (search.charAt(0) == "." || search.charAt(0) == identifierQuote) {
After change:
if (search.charAt(0) == "." || search.charAt(0) == identifierQuote || editor.getTokenAt(Pos(cur.line, token.start)).string == "."|| editor.getTokenAt(Pos(cur.line, token.start)).string == identifierQuote) {
I don't see this issue happening. When I type a.I
, the SQL mode makes .I
a single token, so the check at that line succeeds and nameCompletion
is called.
I don't see this issue happening. When I type
a.I
, the SQL mode makes.I
a single token, so the check at that line succeeds andnameCompletion
is called.
Did you use the sql-hint with hitOption of "tables"?To filter the columns of the table, it will hint the options of sql mode keywords, builtIns and other defaults, such as "IN, INSERT". In my opinion, the table followed by dot(.) with "tables" option in hitOption should hint and filter within the table columns, not the keywords and so on.
Yes, I did. Set up an example script that shows the issue if you want me to look into this.
Set the configuration as follows:
{ tabSize: 2, mode: "sql", theme: "lucario", lineNumbers: true, autoCloseBrackets: true, singleCursorHeightPerLine: false, hintOptions: { completeSingle: false, tables: { "a": ["ID", "BOND_ID", "PARTY_ID"] } } }
,
As these settings works, then type "a.", the columns pop up correctly. Continue typing the word "I", the hint dose not filter from the columns but show the sql keywords and other builtins, such as "IN, INSERT".
Ah, there was some weird feature in the SQL mode that turned off tokenizing of dot-prefixed identifiers unless explicitly enabled, and using "sql"
as mode (rather than a specific dialect) didn't turn that on. Patch d122e55c4818ef72e45939c4c06301bc36cb4a53 should fix that.
Thanks for the works, and best wishes!
Codemirror Version: 5.65.4 I try the sql-hint table option and define table columns. When i input . and codemirror hint the columns correctly, but next word triggers the keywords hint not filter the columns.
https://github.com/codemirror/codemirror5/blob/7f488eb5c12d71ea7ea75e286b7b9c029453a298/addon/hint/sql-hint.js#L267
I find the code here and it should detect that whether the input word is behind the dot(.), then to match the table columns which is on the left.