Skip to content

Commit

Permalink
🔀 Merge pull request #36 from davep/upgrade-fspicker
Browse files Browse the repository at this point in the history
Upgrade `textrual-fspicker`
  • Loading branch information
davep authored Feb 21, 2025
2 parents bce659d + 2db8ca5 commit 075f136
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ platformdirs==4.3.6
pluggy==1.5.0
# via pytest
pre-commit==4.1.0
propcache==0.2.1
propcache==0.3.0
# via aiohttp
# via yarl
pygments==2.19.1
Expand All @@ -109,7 +109,7 @@ textual==1.0.0
textual-dev==1.7.0
textual-enhanced==0.6.0
# via hike
textual-fspicker==0.2.0
textual-fspicker==0.4.0
# via hike
textual-serve==1.1.1
# via textual-dev
Expand Down
2 changes: 1 addition & 1 deletion requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ textual==1.0.0
# via textual-fspicker
textual-enhanced==0.6.0
# via hike
textual-fspicker==0.2.0
textual-fspicker==0.4.0
# via hike
typing-extensions==4.12.2
# via hike
Expand Down
10 changes: 9 additions & 1 deletion src/hike/screens/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
##############################################################################
# Python imports.
from argparse import Namespace
from functools import partial

##############################################################################
# Pyperclip imports.
Expand All @@ -22,6 +23,7 @@
from textual_enhanced.commands import ChangeTheme, Command, Help, Quit
from textual_enhanced.dialogs import ModalInput
from textual_enhanced.screen import EnhancedScreen
from textual_enhanced.tools import add_key

##############################################################################
# Textual fspicker imports.
Expand Down Expand Up @@ -259,6 +261,7 @@ async def _browse_for_file(self, message: OpenFrom) -> None:
),
("All files", lambda _: True),
),
cancel_button=partial(add_key, key="Esc", context=self),
)
):
self.post_message(OpenLocation(chosen))
Expand Down Expand Up @@ -488,7 +491,12 @@ async def action_save_copy_command(self) -> None:
"""Save a copy of the current document to a new file."""
if (suggested := self.query_one(Viewer).filename) is None:
return
if save_to := await self.app.push_screen_wait(FileSave(default_file=suggested)):
if save_to := await self.app.push_screen_wait(
FileSave(
default_file=suggested,
cancel_button=partial(add_key, key="Esc", context=self),
)
):
try:
save_to.write_text(self.query_one(Viewer).source, encoding="utf-8")
except IOError as error:
Expand Down

0 comments on commit 075f136

Please sign in to comment.