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
10 changes: 8 additions & 2 deletions TeXmacs/progs/generic/generic-test.scm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(texmacs-module (generic generic-test)
(:use (generic generic-menu) ))
(:use (generic generic-menu)
(table table-menu) ))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; generic menu functions
Expand All @@ -23,10 +24,15 @@
focus-tag-name :none
(test "bmatrix" 'bmatrix "bmatrix")
(test "Bmatrix" 'Bmatrix "Bmatrix")
(test "tabular" 'tabular "tabular")
(test "tabular*" 'tabular* "centered tabular")
(test "block" 'block "block")
(test "block*" 'block* "centered block")
(test "big-table" 'big-table "big table")
))

(tm-define (regtest-generic)
(let ((n (+ (regtest-focus-tag-name)
)))
(display* "Total: " (object->string n) " tests.\n")
(display "Test suite of generic: ok\n")))
(display "Test suite of generic: ok\n")))
25 changes: 25 additions & 0 deletions TeXmacs/progs/table/table-menu.scm
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,31 @@
---
("Table properties" (open-table-properties)))))

(define (table-inline-variant-context? t)
(tree-in? t '(tabular tabular* wide-tabular block block* wide-block)))

(define (table-inline-variants)
(if (in-math?)
'(tabular tabular* block block*)
'(tabular tabular* wide-tabular block block* wide-block)))

(tm-define (focus-variants-of t)
(:require (table-inline-variant-context? t))
(table-inline-variants))

(tm-define (variant-circulate t forward?)
(:require (table-inline-variant-context? t))
(variant-circulate-in t (table-inline-variants) forward?))

(tm-define (variant-set-keep-numbering t v)
(:require (table-inline-variant-context? t))
(variant-set t v))

(tm-define (focus-tag-name l)
(cond ((== l 'tabular*) "centered tabular")
((== l 'block*) "centered block")
(else (former l))))

(define (cell-halign-icon)
(with h (cell-get-format "cell-halign")
(cond ((== h "l") "tm_cell_left.xpm")
Expand Down
39 changes: 39 additions & 0 deletions devel/202_106.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# [202_106] Fix duplicate names in table environment switching dropdown

### How to test
1. Open Mogan
2. Insert a table using `Alt+t`
3. Click the "tabular" dropdown on the focus toolbar
4. Verify all 6 variants have distinct names:
- 无框表格 (tabular)
- 居中无框表格 (centered tabular)
- 标宽无框表格 (wide tabular)
- 有框表格 (block)
- 居中有框表格 (centered block)
- 标宽有框表格 (wide block)
5. Press `Alt/Option + Shift + v` repeatedly inside a table and verify cycling no longer lands on `big table`.

## 2026/02/27
### What
Added `focus-tag-name` overrides for `tabular*` and `block*` in `TeXmacs/progs/table/table-menu.scm` so they display as "centered tabular" and "centered block" respectively.

### Why
The `focus-tag-name` function strips the `*` suffix from `tabular*` and `block*` (treating them as unnumbered variants of `tabular` and `block`), causing both pairs to display the same name in the table variant dropdown. This results in two duplicate entries: "无框表格" appears twice and "有框表格" appears twice.

The fix adds explicit `focus-tag-name` dispatches for these two tags, using translation keys ("centered tabular" / "centered block") that already exist in all language dictionaries.

## 2026/03/04
### What
- Restricted table variant dropdown / cycling to inline table variants:
- `tabular`, `tabular*`, `wide-tabular`, `block`, `block*`, `wide-block`
- Added table-specific `variant-set-keep-numbering` behavior to avoid numbered/unnumbered star propagation on table variants.
- Extended `TeXmacs/progs/generic/generic-test.scm` with regression tests for:
- `tabular* -> centered tabular`
- `block* -> centered block`
- fallback names such as `big-table -> big table`

### Why
- Similar-environment cycling from a tabular could reach `big-table`, which has incompatible structure for direct node relabeling and could produce a stuck state with `?` placeholders.
- Table stars (`tabular*`, `block*`) encode alignment, not numbering. Reusing generic numbering-preserving variant logic is incorrect for table-specific cycling.

Fixes: https://github.com/XmacsLabs/mogan/issues/2782