Skip to content

[0828] plugin-math-input 改用独立 string port 捕获,修复日志污染 - #4353

Merged
da-liii merged 3 commits into
mainfrom
da/0828/protocol
Aug 18, 2026
Merged

[0828] plugin-math-input 改用独立 string port 捕获,修复日志污染#4353
da-liii merged 3 commits into
mainfrom
da/0828/protocol

Conversation

@da-liii

@da-liii da-liii commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

What

  • 修复 plugin-math-input 的捕获污染 bug:原实现经 tm-with-output-to-string(cout buffer)捕获,boot 层把单参 display 重写到全局 cout,导致捕获窗口内 C++ 日志(如 lazy 模块加载日志)混入发往插件的字符串——会话中首个 math 输入会带日志前缀。
  • 改为 call-with-output-string + dynamic-wind 动态绑定 plugin-input-portplugin-convert.scmmaxima-input.scm 的 handler 输出统一走 plugin-output,与 cout 完全隔离。
  • 新增 TeXmacs/progs/utils/plugins/plugin-cmd-test.scm 纯逻辑测试:覆盖 pre-serialize 各分支(透传/document 剥壳/math 渲染/maxima 自定义 handler)。
  • 新增 TeXmacs/tests/tmu/0828.tmu 测试文档。

Why

单参 display 被 boot-s7.scm 重写到 tm-outputcout,不经过 current-output-port,故 with-output-to-string 捕获会落空,必须显式传 port。

How

  • plugin-output(display s plugin-input-port),带 port 参数的 display 走 original-display 真 port 语义。
  • call-with-plugin-output-string:独立 string port 捕获,dynamic-wind 保证异常时恢复端口。

测试

  • xmake r plugin-cmd-test:13/13 通过(含首个 math 调用无污染验证)
  • xmake r 0828:63/63 通过

🤖 Generated with Claude Code

da-liii and others added 3 commits August 17, 2026 16:47
tm-with-output-to-string 基于全局 cout buffer,捕获窗口内 C++ 日志
(如 lazy 模块加载)会混入发往插件的字符串。改为 call-with-output-string
+ 动态绑定 plugin-input-port,plugin-convert.scm 与 maxima-input.scm 的
handler 输出统一走 plugin-output,与 cout 完全隔离。顺带移除无调用者的
debug 函数 convert-test。

新增 plugin-cmd-test.scm 覆盖 pre-serialize 各分支及 maxima 自定义 handler。

Co-Authored-By: Claude <noreply@anthropic.com>
@da-liii
da-liii merged commit 7cb9ce1 into main Aug 18, 2026
3 checks passed
@da-liii
da-liii deleted the da/0828/protocol branch August 18, 2026 02:51
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.

1 participant