Repository navigation
feat(ui): 只读 SQL / DDL 补语法高亮 (#9) - #10
Merged
Merged
Conversation
added 4 commits
October 29, 2026 09:49
详情面板的 DDL 页、建库 / 修改库对话框的脚本预览、结构同步的 DDL 比较与部署脚本 一直是裸文本,而查询编辑器和表设计器「SQL 预览」早就有高亮 —— 同一屏两种待遇。 - 新增 lib/theme/sql_highlight.dart:只读区走同步 TextSpan 高亮 (re_highlight 的 TextSpanRenderer),首帧即彩色,不引入编辑器那条 isolate 回帧的「慢半拍」;解析异常或结果掉了字符一律退回裸文本。 - 明暗配色表原本抄了三份(query_page / table_designer_page / routine_design_page,后者的公开名还被四个设计页 import),收成一处, 六个编辑器调用点统一走 sqlEditorTheme。 - 结构同步的「消息日志」不是 SQL,保持裸文本。 - 相应地,断言这些区域文本的用例改 findRichText: true。
CI 的 flutter analyze 报 unnecessary_non_null_assertion:showEmpty 的定义里 已含 emptyHint != null,局部变量的流分析已经把参数提升成非空了。
「命中的子 span 不带字号」这条把兜底文本也算进去了:re_highlight 的 TextSpanRenderer 给没命中 scope 的片段直接挂 base 样式(本来就带字号), 于是断言必红。改成只看样式不等于 base 的那些 span。
Text.rich → SelectableText.rich:整段复制走右上角按钮,想只取一列名 / 一段定义时得能就地划选(建库改库的脚本预览、结构同步的脚本区本来就是这样)。 复制按钮不动。用例里按内容定位那条 SelectableText,顺带钉住 selectionEnabled。
SpringHgui
force-pushed
the
feat/issue9-ddl-syntax-highlight
branch
from
October 29, 2026 03:43
7056500 to
e0535f8
Compare
2 tasks
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.
Closes #9
详情面板的 DDL 页、建库 / 修改库对话框的脚本预览、结构同步的 DDL 比较与部署脚本一直是裸文本,而查询编辑器和表设计器「SQL 预览」早就有高亮——同一屏两种待遇。
改动:
lib/theme/sql_highlight.dart:只读区走同步 TextSpan 高亮(re_highlight的TextSpanRenderer),首帧即彩色,不引入编辑器那条 isolate 回帧的「慢半拍」;解析异常、或解析结果掉了字符,一律整段退回裸文本(宁可不上色,也不能让 DDL 少一截)。query_page/table_designer_page/routine_design_page,后者的公开名还被四个设计页 import 借用),收成一处,六个编辑器调用点统一走sqlEditorTheme。Consolas+monospace回落(详情面板 DDL 页原来是monospace)。Test plan
test/sql_highlight_test.dart(离线):文本无损、关键字 / 注释确实上色、明暗各取各表、字号由根 span 兜底、memo 命中与作废、配色表 key 一致findRichText: true(Text→Text.rich后默认 finder 看不见富文本)