Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide more commands that aren't applicable at certain times #16

Merged
merged 1 commit into from
Feb 16, 2025
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: 5 additions & 5 deletions src/hike/providers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ def commands(self) -> CommandHits:
The commands for the command palette.
"""
yield from self._maybe(Backward)
yield BookmarkLocation()
yield from self._maybe(BookmarkLocation)
yield ChangeCommandLineLocation()
yield ChangeNavigationSide()
yield ChangeTheme()
yield CopyLocationToClipboard()
yield CopyMarkdownToClipboard()
yield from self._maybe(CopyLocationToClipboard)
yield from self._maybe(CopyMarkdownToClipboard)
yield from self._maybe(Edit)
yield from self._maybe(Forward)
yield Help()
Expand All @@ -72,8 +72,8 @@ def commands(self) -> CommandHits:
yield JumpToHistory()
yield JumpToLocalBrowser()
yield Quit()
yield Reload()
yield SaveCopy()
yield from self._maybe(Reload)
yield from self._maybe(SaveCopy)
yield SearchBookmarks()
yield ToggleNavigation()

Expand Down
11 changes: 11 additions & 0 deletions src/hike/screens/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,17 @@ def check_action(self, action: str, parameters: tuple[object, ...]) -> bool | No
return self.query_one(Viewer).history.can_go_backward or None
if action == Edit.action_name():
return self.query_one(Viewer).is_editable or None
if action in (
command.action_name()
for command in (
BookmarkLocation,
CopyLocationToClipboard,
CopyMarkdownToClipboard,
Reload,
SaveCopy,
)
):
return self.query_one(Viewer).location is not None
return True

@on(Reload)
Expand Down
Loading