[201_98] 优化列表功能#3136
[201_98] 优化列表功能#3136wumoin merged 1 commit intomainMoganLab/mogan:mainfrom hongwei/201_98/optimize_listMoganLab/mogan:hongwei/201_98/optimize_listCopy head branch name to clipboard
Conversation
Greptile Summary本 PR 优化了 TeXmacs 中的列表编辑功能,主要包括:将 所有发现均为 P2 级别的代码质量建议,不影响合并。 Confidence Score: 5/5所有问题均为 P2 代码质量建议,不影响功能正确性,可安全合并 核心列表缩进/反缩进逻辑实现完整,边界条件(最外层列表止住、concat 包装处理、光标位置恢复)均已考虑。无 P0/P1 级别问题,仅存在代码重复和菜单提示不一致等维护性建议。 TeXmacs/progs/generic/generic-edit.scm 中本地重定义了 DRD tag list 函数,存在轻微维护风险 Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["用户按 Tab / Shift+Tab"] --> B["list-tab-context-match?"]
B -- "未找到 item marker" --> Z["不处理,调用默认行为"]
B -- "找到 item marker" --> C{"forwards?"}
C -- "Tab" --> D["find-item-wrapper-and-list"]
D --> F{"item-index > 0?"}
F -- "否" --> Z
F -- "是" --> G["find-previous-item-index"]
G --> H{"前一项已有子列表?"}
H -- "是" --> I["复用已有子列表"]
H -- "否" --> J["新建空子列表"]
I --> K["附带后置子列表内容并入"]
J --> K
K --> L["tree-remove! 当前 item"]
L --> M["go-to-moved-list-item 恢复光标"]
C -- "Shift+Tab" --> N["确认 sublist/parent-list/outer-list"]
N --> P{"outer-list 存在?"}
P -- "否" --> Z
P -- "是" --> Q{"items-before-count > 0?"}
Q -- "非首项" --> R["保留 sublist,插入到其后"]
Q -- "首项" --> S["删除 sublist,在原位插入"]
R --> T{"有后续兄弟节点?"}
S --> T
T -- "是" --> U["重建同类型 sublist"]
T -- "否" --> V["go-to-moved-list-item 恢复光标"]
U --> V
|
| (define (list-tab-context-match? forwards?) | ||
| (let* ((item (current-list-item-marker)) | ||
| (enum? (in-enumerate-context?)) | ||
| (itemize? (in-itemize-context?)) | ||
| (description? (in-description-context?)) | ||
| (match? (and item | ||
| (or (and (or enum? itemize?) (tree-is? item 'item)) | ||
| (and description? (tree-is? item 'item*)))))) | ||
| match?)) |
| (define (list-item-marker-node? t) | ||
| (or (tree-is? t 'item) | ||
| (tree-is? t 'item*))) | ||
|
|
||
| (define (list-item-wrapper-node? t) | ||
| (and (tree-is? t 'concat) | ||
| (> (tree-arity t) 0) | ||
| (list-item-marker-node? (tree-ref t 0)))) |
There was a problem hiding this comment.
| (menu-bind itemize-menu | ||
| ("Default" (make-tmlist 'itemize)) | ||
| ((shortcut "Default" "- space") (make-tmlist 'itemize)) | ||
| --- | ||
| ("Bullets" (make-tmlist 'itemize-dot)) | ||
| ("Dashes" (make-tmlist 'itemize-minus)) | ||
| ("Arrows" (make-tmlist 'itemize-arrow))) |
No description provided.