Repository navigation
feat: #184 support continuous SQL completion - #232
Merged
Merged
Conversation
liuxy0551
reviewed
Oct 29, 2026
| } | ||
|
|
||
| const isKeyword = item.kind === languages.CompletionItemKind.Keyword; | ||
| const isParenFunction = item.insertText === undefined && isKeyword && hasFunctionContext; |
Collaborator
There was a problem hiding this comment.
这里用 hasFunctionContext 判定具体补全项存在作用域混淆的问题。
hasFunctionContext 代表的是“当前光标位置语法上是否允许出现函数”。在 SQL 中,几乎所有核心表达式位置(如 SELECT | 投影列、WHERE | 条件、ON | 连接条件等)都允许函数调用,因此该标志在这些位置恒为 true。
如果直接用 item.insertText === undefined && isKeyword && hasFunctionContext 判定,会导致在上述位置,所有普通关键字(例如 DISTINCT、CASE、AND、OR 等)都被判定为 isParenFunction = true,从而全部丢失了尾随空格。
更严重的是,下方的 advancesContext 依然判定 (item.insertText === undefined && isKeyword) 为 true 并挂载了 retriggerSuggestCommand,导致用户选中 DISTINCT 后插入无空格裸词并立即在原地重新触发建议框,建议框过滤出 DISTINCT 再次弹窗,导致无法通过回车/Tab 结束补全,陷入死循环。
建议:
- 区分真正的函数项与普通关键字(不能仅凭光标位置语法上下文)。若为函数关键字,应转换为带参片段(如
${name}($1))并标记为 snippet; - 对于不带空格和括号的裸词,
advancesContext绝不能挂载retriggerSuggestCommand,避免原地重复触发。
Contributor
Author
There was a problem hiding this comment.
这个后续配合dt-sql-parser提取Function后再做
jin-sir
force-pushed
the
feat/continuous-sql-completion
branch
from
October 29, 2026 09:30
cdce715 to
50fbb40
Compare
Cythia828
approved these changes
Oct 30, 2026
liuxy0551
approved these changes
Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
issue
#184
功能
支持 SQL 连续补全,提升 SQL 编写效率。
预览地址
暂无
变更描述
提供 continuousCompletion 配置参数,默认关闭;
将 continuousCompletion 设置为 true 可以开启连续补全:当选中一个补全项后,只要插入行为把光标带入了新的语法上下文,就会自动再次触发建议框,从而无需再次输入即可展示下一组建议。具体来说: