Skip to content

Commit 075f136

Browse files
authored
🔀 Merge pull request #36 from davep/upgrade-fspicker
Upgrade `textrual-fspicker`
2 parents bce659d + 2db8ca5 commit 075f136

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

requirements-dev.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ platformdirs==4.3.6
8585
pluggy==1.5.0
8686
# via pytest
8787
pre-commit==4.1.0
88-
propcache==0.2.1
88+
propcache==0.3.0
8989
# via aiohttp
9090
# via yarl
9191
pygments==2.19.1
@@ -109,7 +109,7 @@ textual==1.0.0
109109
textual-dev==1.7.0
110110
textual-enhanced==0.6.0
111111
# via hike
112-
textual-fspicker==0.2.0
112+
textual-fspicker==0.4.0
113113
# via hike
114114
textual-serve==1.1.1
115115
# via textual-dev

requirements.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ textual==1.0.0
5050
# via textual-fspicker
5151
textual-enhanced==0.6.0
5252
# via hike
53-
textual-fspicker==0.2.0
53+
textual-fspicker==0.4.0
5454
# via hike
5555
typing-extensions==4.12.2
5656
# via hike

src/hike/screens/main.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
##############################################################################
44
# Python imports.
55
from argparse import Namespace
6+
from functools import partial
67

78
##############################################################################
89
# Pyperclip imports.
@@ -22,6 +23,7 @@
2223
from textual_enhanced.commands import ChangeTheme, Command, Help, Quit
2324
from textual_enhanced.dialogs import ModalInput
2425
from textual_enhanced.screen import EnhancedScreen
26+
from textual_enhanced.tools import add_key
2527

2628
##############################################################################
2729
# Textual fspicker imports.
@@ -259,6 +261,7 @@ async def _browse_for_file(self, message: OpenFrom) -> None:
259261
),
260262
("All files", lambda _: True),
261263
),
264+
cancel_button=partial(add_key, key="Esc", context=self),
262265
)
263266
):
264267
self.post_message(OpenLocation(chosen))
@@ -488,7 +491,12 @@ async def action_save_copy_command(self) -> None:
488491
"""Save a copy of the current document to a new file."""
489492
if (suggested := self.query_one(Viewer).filename) is None:
490493
return
491-
if save_to := await self.app.push_screen_wait(FileSave(default_file=suggested)):
494+
if save_to := await self.app.push_screen_wait(
495+
FileSave(
496+
default_file=suggested,
497+
cancel_button=partial(add_key, key="Esc", context=self),
498+
)
499+
):
492500
try:
493501
save_to.write_text(self.query_one(Viewer).source, encoding="utf-8")
494502
except IOError as error:

0 commit comments

Comments
 (0)