Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions TeXmacs/progs/math/math-edit.scm
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,18 @@ list | boolean
(rb (caddr body)))
`(symbol-completion
,(string-append lb rb)))))
;; Case 4: math-separator
((math-separator)
(and (string? (cadr body))
`(symbol-completion
,(if (== (cadr body) "<nobracket>")
"<mid-.>"
(string-append "<mid-"
(if (and (string-starts? (cadr body) "<")
(string-ends? (cadr body) ">"))
(substring (cadr body) 1
(- (string-length (cadr body)) 1))
(cadr body)) ">")))))
;; 预留位置:可以在此添加其他函数的处理逻辑

(else #f)))))))))))
Expand Down
22 changes: 22 additions & 0 deletions devel/201_96.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 201_96 修复tabcyc 中`|`和`[`的一些错误
## 如何测试
1. 启动程序,进入数学模式。
2. 测试 `|`的tab cycling,新的实现补充了对`math-separator`的补充,相较于旧的实现会新增加一个选项 (注:'|'的第5项无法被渲染出来,需要之后更新`<barsuchthat>`字体)
3. 测试 `[`的tab cycling (原先的实现会导致组件上的所有选项都被渲染成红色)


## 2026/03/12 修复tabcyc 中`|`和`[`的一些错误
### What
- 在 `lambda-to-symbol` 中补充了 `math-separator` 分支,把函数型绑定反解成 `"<mid-...>"` 形式的 completion 字符串。
- 在 `math_font_rep::search_font` 中放宽了 fallback 字符检查,允许 `[`、`]`、`|` 作为普通候选字符串继续走数学字体渲染流程,而不是直接落进 `error_font`。

### Why
- 原先 `lambda-to-symbol` 只处理大运算符、prime 和括号对,没有处理 `math-separator`,导致 middle separator 在 Tab 补全里缺少专门的显示形式。
- `[`、`]`、`|` 这些字符串如果走到 `math_font` 的错误分支,会被 `error_font` 强制画成红色,popup 的显示会误导调试。

### How
- `math-separator` 的 completion 名称通过字符串拼接得到:
- 普通情形:`"<mid-" + sep + ">"`
- `"<nobracket>"` 特判为 `"<mid-.>"`
- `math_font.cpp` 中把 `[`、`]`、`|` 加入允许字符集合,避免它们在补全 popup 中被当成非法数学字体输入。

3 changes: 2 additions & 1 deletion src/Graphics/Fonts/math_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ math_font_rep::search_font (string& s, font& fn) {
int i, n= N (s);
for (i= 0; i < n; i++)
if ((!is_digit (s[i])) && (!is_alpha (s[i])) && (s[i] != '.') &&
(s[i] != '\\') && (s[i] != '_')) {
(s[i] != '\\') && (s[i] != '_') && (s[i] != '[') && (s[i] != ']') &&
(s[i] != '|')) {
fn= error_fn;
return;
}
Expand Down
Loading