Skip to content

[6118] 修复插入空 document 节点导致编辑器崩溃问题 - #4721

Merged
MoonL79 merged 1 commit into
mainfrom
da/6118/empty-document
Oct 14, 2026
Merged

MoonL79 merged 1 commit into
mainfrom
da/6118/empty-document

Conversation

@MoonL79

@MoonL79 MoonL79 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

问题背景

在插入子节点数为 0 的空 document 节点时,C++ edit_text_rep::insert_tree 处理 is_document 分支破坏了 buffer 树结构或产生负索引越界,导致编辑器抛出 Throwing concat expected / invalid modification 并挂死崩溃;在 OCR 处理流程中,空串或纯空白文本也会经 ocr-insert-text-by-cursor 触发该问题及产生多余回车。

改动内容

  1. C++ 核心防御:在 src/Edit/Modify/edit_text.cpp 中,为 insert_tree 的 is_document(t) 分支头部增加 if (N (t) == 0) return; 保护。
  2. Scheme 光标插入层防御:在 TeXmacs/plugins/ocr/progs/ocr/ocr-insert.scm 中,修改 ocr-insert-text-by-cursor,遇到空串或纯空白文本直接返回 #f。
  3. 集成测试:添加 TeXmacs/tests/6118.scm 测试用例,覆盖空 document 节点插入及 OCR 空文本拦截。

@da-liii da-liii left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MoonL79
MoonL79 merged commit f1d8e4a into main Oct 14, 2026
6 checks passed
@MoonL79
MoonL79 deleted the da/6118/empty-document branch October 14, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants