Skip to content

Commit 5d83e61

Browse files
authored
Merge pull request #342 from erodriguez23777/fix/visual-mode-yank
fix: include last character when yanking in visual mode
2 parents 03b250a + 98378e3 commit 5d83e61

6 files changed

Lines changed: 26 additions & 8 deletions

File tree

.coverage

52 KB
Binary file not shown.

docs/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
## [Unreleased]
22

33
### Fixed
4-
- Fixed the test snapshot for test_select_post_method
4+
- Fixed themes not auto-reloading when the theme file is a symlink.
5+
- Fixed last character being omitted when yanking text in visual mode.
56

67
### Changed
78
- `MethodSelector`: uppercase letters can now be used to change the method.

src/posting/app.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,14 @@ async def watch_themes(self) -> None:
13641364

13651365
from watchfiles import awatch
13661366

1367-
async for changes in awatch(self.settings.theme_directory):
1367+
paths_to_watch = {self.settings.theme_directory}
1368+
1369+
if self.settings.theme_directory.exists():
1370+
for p in self.settings.theme_directory.iterdir():
1371+
if p.is_symlink():
1372+
paths_to_watch.add(p.resolve().parent)
1373+
1374+
async for changes in awatch(*paths_to_watch):
13681375
for _change_type, file_path in changes:
13691376
if file_path.endswith((".yml", ".yaml")):
13701377
try:
@@ -1378,10 +1385,6 @@ async def watch_themes(self) -> None:
13781385
try:
13791386
self._watch_theme(theme.name)
13801387
except Exception as e:
1381-
# I don't think we want to notify here, as editors often
1382-
# use heuristics to determine whether to save a file. This could
1383-
# prove jarring if we pop up a notification without the user
1384-
# explicitly saving the file in their editor.
13851388
log.warning(f"Error refreshing CSS: {e}")
13861389

13871390
def on_mount(self) -> None:

src/posting/widgets/request/url_bar.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class UrlInput(PostingInput):
6060
BINDINGS = [
6161
Binding("down", "app.focus_next", "Focus next", show=False),
6262
Binding("alt+down", "jump_to_path_param", "Jump to Path param", show=False),
63+
Binding("ctrl+y", "copy_url", "Copy URL", show=False),
6364
]
6465

6566
@dataclass
@@ -132,6 +133,13 @@ def action_jump_to_path_param(self) -> None:
132133
self.PathParamJumpRequestedFromUrlInput(name=name, input=self)
133134
)
134135
break
136+
137+
def action_copy_url(self) -> None:
138+
"""Copy the URL to the clipboard."""
139+
url = self.value
140+
if url:
141+
self.app.copy_to_clipboard(url)
142+
self.notify(f"Copied URL to clipboard: {url}")
135143

136144

137145
class SendRequestButton(Button, can_focus=False):

src/posting/widgets/text_area.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,13 @@ def action_cursor_word_right(self, select: bool = False) -> None:
499499
return super().action_cursor_word_right(self.visual_mode or select)
500500

501501
def action_copy_to_clipboard(self) -> None:
502-
text_to_copy = self.selected_text
502+
if self.visual_mode and not self.selection.is_empty:
503+
start, end = sorted([self.selection.start, self.selection.end])
504+
505+
inclusive_end = (end[0], end[1] + 1)
506+
text_to_copy = self.get_text_range(start, inclusive_end)
507+
else:
508+
text_to_copy = self.selected_text
503509
if text_to_copy:
504510
message = f"Copied {len(text_to_copy)} characters."
505511
title = "Selection copied"

tests/__snapshots__/test_snapshots/TestHelpScreen.test_help_screen_appears.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)