feat(cli): add --normal flag to start TUI in outline navigation mode#54
Open
theskumar wants to merge 1 commit into
Open
feat(cli): add --normal flag to start TUI in outline navigation mode#54theskumar wants to merge 1 commit into
theskumar wants to merge 1 commit into
Conversation
637e601 to
17f2c76
Compare
When launching treemd with a file argument from an external file picker (e.g. fzf), buffered input events (like the Enter keypress used to confirm selection) leak into treemd's event loop. This causes the TUI to enter interactive element mode and scroll the outline to the last heading instead of starting cleanly in normal/outline navigation mode. The --normal flag: - Forces the TUI to start in normal (outline navigation) mode - Drains any buffered TTY input events before entering the main loop - Blocks the first enter_interactive_mode call to prevent mode switching This is useful for integrations where treemd is launched from tmux keybindings, shell scripts, or other tools that pipe a file path into treemd after an interactive selection step.
17f2c76 to
f5e3447
Compare
Contributor
|
Hi @theskumar — thanks for the PR and for digging into this! 🙏 I can't reproduce the behavior you're describing. treemd should already start in outline/normal navigation mode by default. The sequence:
So a --normal flag would effectively be a no-op against the default behavior, which makes me think something else is going on in your setup rather than a treemd default? Could you help me narrow it down?
|
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.
Problem
treemd file.mdalways starts in interactive element mode. Users who prefer outline navigation have to pressEscevery time to switch to normal mode. There is no way to control the startup mode.Solution
Add a
--normalCLI flag that starts the TUI in outline navigation mode.What the flag does
enter_interactive_mode: the first call is blocked (one shot), keeping the TUI inAppMode::Normal. Subsequentikeypresses enter interactive mode as usual.Normalwith a redraw. This ensures a clean starting state regardless of what triggered during the first frame.Usage with an external file picker
Testing
Two new integration tests verify the flag is accepted by the CLI parser and appears in help output.