fix: #165 disable completion in comments - #227
Open
liuxy0551 wants to merge 2 commits into
Open
Conversation
Collaborator
Cythia828
reviewed
Aug 12, 2026
Comment on lines
+150
to
+154
| const textBeforePosition = model.getValueInRange( | ||
| new Range(1, 1, position.lineNumber, position.column) | ||
| ); | ||
| // 在光标处追加哨兵字符,避免将刚结束的块注释误判为仍在注释中 | ||
| const tokenizedLines = editor.tokenize(`${textBeforePosition}x`, model.getLanguageId()); |
Collaborator
There was a problem hiding this comment.
每次补全请求都 getValueInRange 取光标前全部文本(一次大字符串分配),再 editor.tokenize 对整段做 Monarch 分词(又一次大字符串 + 分词)。建议补一个大文件 benchmark 确认回归可接受,如果发现延迟明显,可能需要切换到别的方案
Collaborator
Author
There was a problem hiding this comment.
这个点已经调整了。
当前实现不再读取从文档开头到光标的整段文本,也不再调用 editor.tokenize 对整段前缀重新分词;改成基于 Monaco model 的 tokenization.tokenizeLinesAt(),只对当前行光标前的内容追加哨兵字符后做按行 token 判断。
同时补了一个回归测试,确保注释检测不会再去读取整段文档前缀。
benchmark 这次我先不放在这个 PR 里,主要是 dt-sql-parser 才有 benchmark 流程。主要是这里的改动范围仍然是共享 CompletionAdapter 的实现收敛,当前也已经从“整段前缀复制 + 整段重分词”收敛到“按行 token 判断”。
Collaborator
Author
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.


改动内容
#165
*/之后的位置#注释、块注释及非注释边界场景单测预览地址
https://liuxy0551.github.io/monaco-sql-languages/