Skip to content

Refactor viewer and utility functions; add maximize toggle feature#12

Merged
simonwinther merged 8 commits into
masterfrom
chore/audit-cleanup
Jun 6, 2026
Merged

Refactor viewer and utility functions; add maximize toggle feature#12
simonwinther merged 8 commits into
masterfrom
chore/audit-cleanup

Conversation

@simonwinther

@simonwinther simonwinther commented Jun 6, 2026

Copy link
Copy Markdown
Owner

This pull request introduces a new maximize toggle feature for the viewer and refactors timing utilities throughout the codebase for improved consistency and error handling. The most significant changes are the addition of a maximize/minimize viewer mode, the centralization of timing and formatting helpers, and improved robustness in system command execution.

Viewer maximize toggle and UI improvements:

  • Added a new mapping <M-m> (Alt+m) to toggle the viewer between its configured size and a maximized view, updating documentation in both README.md and doc/cppman.txt. (.claude/worktrees/feat+viewer-maximize-toggle, [1] [2]
  • Implemented maximize logic in viewer.lua, including geometry calculation to ensure the viewer fits within the editor without overflowing. [1] [2]

Timing and utility refactoring:

System command error handling:

  • Wrapped all vim.system calls in pcall to gracefully handle errors and prevent crashes when external commands fail, improving robustness in index.lua, render.lua, and related modules. [1] [2] [3] [4] [5]

Minor improvements and bug fixes:

  • Fixed a bug in the health check logic to correctly handle missing fzf binaries when fzf-lua is configured.
  • Removed unused fields and functions related to timing and pattern tracking in several modules for code simplification. [1] [2] [3] [4] [5] [6] [7] [8]

Remove the unused set_last_pattern/last_pattern plumbing threaded
through picker.lua and both backends; the search pattern already
reaches callers via on_select's argument.

Drop the never-read index.last_load_ms field (and its now-unused
now_ms/uv helpers), and collapse render.lua's duplicate timestamp.
vim.system raises ENOENT synchronously when a binary is missing rather
than returning a non-zero exit code, so a missing sqlite3, cppman, or
python3 produced an uncaught stack trace instead of the friendly errors
the code already defines.

Wrap the four spawn sites (run_sqlite, cppman_base_dir, run_cppman,
render_cached_page) in pcall and route spawn failures into each caller's
existing error channel. No caller logic changes.
now_ms and the elapsed-ms formatter were each duplicated across modules
(picker/render/viewer for timing, common/viewer for formatting). Move
both into a new cppman.util leaf module and update call sites. format_ms
keeps the viewer's nil-as-cached guard, a harmless superset for the
picker callers that always pass a number.
follow_word re-inlined the same picker.open call (identical on_select
wiring) that open_picker_for_back already provides. Route through the
helper after pushing the history snapshot; behavior is unchanged.
@simonwinther simonwinther force-pushed the chore/audit-cleanup branch from f652aca to 87910c5 Compare June 6, 2026 14:30
Maximizes the viewer float to fill the editor and re-renders the page to
the new width; toggling again restores the configured size. No-op when
the configured viewer size already fills the screen.
@simonwinther simonwinther force-pushed the chore/audit-cleanup branch from 87910c5 to f7f46aa Compare June 6, 2026 14:37
@simonwinther simonwinther merged commit 4f881dd into master Jun 6, 2026
7 checks passed
@simonwinther simonwinther deleted the chore/audit-cleanup branch June 6, 2026 14:51
@simonwinther simonwinther restored the chore/audit-cleanup branch June 6, 2026 16:35
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