Skip to content

fix(ui): restore mouse after source editor return - #276

Merged
umputun merged 1 commit into
umputun:masterfrom
phewitt:fix/source-editor-mouse-restore
Jul 18, 2026
Merged

umputun merged 1 commit into
umputun:masterfrom
phewitt:fix/source-editor-mouse-restore

Conversation

@phewitt

@phewitt phewitt commented Jul 18, 2026

Copy link
Copy Markdown

Problem

Opening a source file with e releases the terminal through tea.ExecProcess, but the source-editor completion path does not restore mouse tracking afterward. This leaves mouse input disabled after both clean and error returns.

Solution

Mirror the existing annotation-editor behavior by re-enabling mouse cell motion when the session started with mouse tracking enabled. Preserve the source-editor reload behavior by batching restoration with the reload command when both are needed, while continuing to respect --no-mouse.

Fixes #275

Mirror the annotation editor's terminal restoration while preserving
source reload behavior and respecting disabled mouse tracking.
@phewitt
phewitt marked this pull request as ready for review July 18, 2026 00:32
@phewitt
phewitt requested a review from umputun as a code owner July 18, 2026 00:32

@umputun umputun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

logic looks correct and matches the annotation path from #235. All five return paths restore mouse cell motion, --no-mouse still wins via the mouseTracking gate, and batching with the reload cmd is safe. One test-coverage nit before merge, the added tests don't actually pin the fix in place:

  • openSourceEditor sets restoreMouse: m.cfg.mouseTracking (app/ui/editor.go:154) inside the tea.ExecProcess completion closure, but no test invokes that closure, so deleting the line leaves every test green while reintroducing the bug. A case that sets mouseTracking=true and asserts the propagated flag would catch it.
  • the stale-tree (:359) and changed-file (:363) branches return restoreMouseCmd, but the only tests covering them (SkipsReloadWhen*) leave restoreMouse false and assert cmd == nil, so reverting either to return m, nil still passes. Extend the RestoresMouseTracking table with a restoreMouse:true case that hits each mismatch branch.

both minor, production behavior is right on all five paths.

@umputun
umputun merged commit 33b0888 into umputun:master Jul 18, 2026
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.

Mouse tracking is not restored after source editor exits

2 participants