Refactor viewer and utility functions; add maximize toggle feature#12
Merged
Conversation
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.
f652aca to
87910c5
Compare
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.
87910c5 to
f7f46aa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
<M-m>(Alt+m) to toggle the viewer between its configured size and a maximized view, updating documentation in bothREADME.mdanddoc/cppman.txt. (.claude/worktrees/feat+viewer-maximize-toggle, [1] [2]viewer.lua, including geometry calculation to ensure the viewer fits within the editor without overflowing. [1] [2]Timing and utility refactoring:
util.lua(now_ms,format_ms), replacing duplicated code in multiple files and ensuring consistent elapsed time reporting. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]System command error handling:
vim.systemcalls inpcallto gracefully handle errors and prevent crashes when external commands fail, improving robustness inindex.lua,render.lua, and related modules. [1] [2] [3] [4] [5]Minor improvements and bug fixes:
fzfbinaries whenfzf-luais configured.