Conversation
This reverts commit 90c676f.
d22f767 to
479d301
Compare
There was a problem hiding this comment.
Pull request overview
该 PR 旨在优化启动阶段的缓冲区/视图复用逻辑:在首次启动加载欢迎文档、或通过“打开方式/命令行”启动打开文件时,复用启动时的空白缓冲区,避免额外出现一个“无标题”缓冲区;同时在存在启动文件参数时不再加载欢迎文档。
Changes:
- 启动阶段加载欢迎文档改为调用
(mogan-welcome-startup),并在无启动文件参数时才加载欢迎文档 - 新增 Scheme API
load-buffer-into-current,用于在启动阶段将目标文档加载进当前空白 scratch buffer - 重构欢迎文档路径逻辑(抽出
mogan-welcome-path),并补充开发记录文档(新增 222_42、删除 222_34)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/System/Boot/init_texmacs.cpp | 启动阶段根据是否有外部启动文件决定是否加载欢迎文档;首次文件用新 Scheme API 复用当前缓冲区加载 |
| TeXmacs/progs/texmacs/texmacs/tm-files.scm | 新增 load-buffer-into-current,并调整 load-buffer-open 的逻辑(移除旧的 scratch buffer 关闭逻辑) |
| TeXmacs/progs/doc/help-funcs.scm | 抽出 mogan-welcome-path,新增 mogan-welcome-startup 用于启动阶段复用缓冲区加载欢迎文档 |
| devel/222_42.md | 新增本次改动的开发记录与测试步骤 |
| devel/222_34.md | 删除旧开发记录文档 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ((buffer-exists? name) | ||
| ;; 复用当前空白缓冲区前,优先切换到已打开的目标缓冲区。 | ||
| (load-buffer-open name opts) | ||
| (buffer-close cur)) |
There was a problem hiding this comment.
load-buffer-into-current closes cur unconditionally in the (buffer-exists? name) branch. When options include :background, load-buffer-open is a no-op (see its (in? :background opts) branch), so this will close the current scratch buffer even though no buffer switch occurred. Consider either rejecting/ignoring :background (and :new-window) for this helper, or only calling buffer-close cur when you actually switched away from cur (i.e., not in background mode).
| (buffer-close cur)) | |
| ;; 仅在非后台、非新窗口模式下,才关闭当前缓冲区。 | |
| (if (and (nin? :background opts) | |
| (nin? :new-window opts)) | |
| (buffer-close cur))) |
| (let* ((doc (tree-import target (url-format target)))) | ||
| (buffer-rename cur name) | ||
| (buffer-set name doc) | ||
| (load-buffer-open name opts)))) |
There was a problem hiding this comment.
load-buffer-into-current uses tree-import and then renames/overwrites the current scratch buffer without checking for import failure. Elsewhere (e.g., revert-buffer-revert) the code checks (== t (tm->tree "error")) to surface an error message. Consider adding a similar check before buffer-rename/buffer-set, so a corrupted/unsupported file doesn’t silently replace the current buffer with an error tree.
|
正确的解法可能是这个:#2823 |
如何测试
%APPDATA%\moganlab\system\settings.scm后启动预期:仅显示欢迎文档,不出现额外“无标题”
.tmu文件预期:仅显示目标文件,不出现额外“无标题”
预期:显示一个空白文档
2026/02/10
What
Why