riched 1.3.2__tar.gz → 1.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. {riched-1.3.2 → riched-1.3.3}/.gitignore +2 -0
  2. {riched-1.3.2 → riched-1.3.3}/PKG-INFO +1 -1
  3. {riched-1.3.2 → riched-1.3.3}/pyproject.toml +1 -1
  4. {riched-1.3.2 → riched-1.3.3}/src/rich_editor/editor.py +13 -0
  5. {riched-1.3.2 → riched-1.3.3}/tests/test_dirty_buffers.py +30 -0
  6. {riched-1.3.2 → riched-1.3.3}/.python-version +0 -0
  7. {riched-1.3.2 → riched-1.3.3}/AGENTS.md +0 -0
  8. {riched-1.3.2 → riched-1.3.3}/README.md +0 -0
  9. {riched-1.3.2 → riched-1.3.3}/docs/command-palette.svg +0 -0
  10. {riched-1.3.2 → riched-1.3.3}/docs/markdown-preview.svg +0 -0
  11. {riched-1.3.2 → riched-1.3.3}/docs/python-buffer.svg +0 -0
  12. {riched-1.3.2 → riched-1.3.3}/docs/search-replace.svg +0 -0
  13. {riched-1.3.2 → riched-1.3.3}/src/rich_editor/__init__.py +0 -0
  14. {riched-1.3.2 → riched-1.3.3}/src/rich_editor/app.py +0 -0
  15. {riched-1.3.2 → riched-1.3.3}/src/rich_editor/bindings.yaml +0 -0
  16. {riched-1.3.2 → riched-1.3.3}/src/rich_editor/cli.py +0 -0
  17. {riched-1.3.2 → riched-1.3.3}/src/rich_editor/formatting.py +0 -0
  18. {riched-1.3.2 → riched-1.3.3}/src/rich_editor/keybindings.py +0 -0
  19. {riched-1.3.2 → riched-1.3.3}/src/rich_editor/quick_open.py +0 -0
  20. {riched-1.3.2 → riched-1.3.3}/src/rich_editor/screens.py +0 -0
  21. {riched-1.3.2 → riched-1.3.3}/src/rich_editor/settings.py +0 -0
  22. {riched-1.3.2 → riched-1.3.3}/src/rich_editor/syntax.py +0 -0
  23. {riched-1.3.2 → riched-1.3.3}/tests/__init__.py +0 -0
  24. {riched-1.3.2 → riched-1.3.3}/tests/helpers.py +0 -0
  25. {riched-1.3.2 → riched-1.3.3}/tests/runner.py +0 -0
  26. {riched-1.3.2 → riched-1.3.3}/tests/test_cli.py +0 -0
  27. {riched-1.3.2 → riched-1.3.3}/tests/test_command_palette.py +0 -0
  28. {riched-1.3.2 → riched-1.3.3}/tests/test_create_file.py +0 -0
  29. {riched-1.3.2 → riched-1.3.3}/tests/test_editor_shortcuts.py +0 -0
  30. {riched-1.3.2 → riched-1.3.3}/tests/test_file_io.py +0 -0
  31. {riched-1.3.2 → riched-1.3.3}/tests/test_file_tree.py +0 -0
  32. {riched-1.3.2 → riched-1.3.3}/tests/test_footer.py +0 -0
  33. {riched-1.3.2 → riched-1.3.3}/tests/test_formatting.py +0 -0
  34. {riched-1.3.2 → riched-1.3.3}/tests/test_markdown_preview.py +0 -0
  35. {riched-1.3.2 → riched-1.3.3}/tests/test_quick_open.py +0 -0
  36. {riched-1.3.2 → riched-1.3.3}/tests/test_refresh.py +0 -0
  37. {riched-1.3.2 → riched-1.3.3}/tests/test_replace.py +0 -0
  38. {riched-1.3.2 → riched-1.3.3}/tests/test_syntax.py +0 -0
  39. {riched-1.3.2 → riched-1.3.3}/uv.lock +0 -0
@@ -74,3 +74,5 @@ try*
74
74
  secrets.toml
75
75
  keys.log
76
76
  graphify-out/
77
+ .commandcode/
78
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: riched
3
- Version: 1.3.2
3
+ Version: 1.3.3
4
4
  Summary: Terminal Editor with VS Code Keybindings
5
5
  Project-URL: Repository, https://github.com/hoishing/riched
6
6
  Requires-Python: >=3.12
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "riched"
3
- version = "1.3.2"
3
+ version = "1.3.3"
4
4
  description = "Terminal Editor with VS Code Keybindings"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -4,6 +4,7 @@ from collections.abc import Callable
4
4
  import re
5
5
  from typing import Protocol, cast
6
6
 
7
+ from textual import events
7
8
  from textual.widgets import TextArea
8
9
 
9
10
  from .keybindings import build_static_bindings
@@ -54,6 +55,18 @@ class RichedTextArea(TextArea):
54
55
 
55
56
  BINDINGS = build_static_bindings("editor")
56
57
 
58
+ async def _on_key(self, event: events.Key) -> None:
59
+ if event.key == "escape":
60
+ from .app import RichedApp
61
+
62
+ app = self.app
63
+ if isinstance(app, RichedApp) and not app._is_file_tree_visible():
64
+ app.action_file_tree_quit_check()
65
+ event.stop()
66
+ event.prevent_default()
67
+ return
68
+ await super()._on_key(event) # type: ignore[misc]
69
+
57
70
  def _clamp_location(self, location: tuple[int, int]) -> tuple[int, int]:
58
71
  row, column = location
59
72
  row = max(0, min(row, self.document.line_count - 1))
@@ -68,6 +68,36 @@ async def test_quit_dirty_discard_keeps_file() -> None:
68
68
  assert f.read_text() == "orig"
69
69
 
70
70
 
71
+ async def test_editor_escape_visible_tree_does_nothing() -> None:
72
+ _, f, app = _file_app("editor-escape-visible.txt", "foo", root_is_tmp=True)
73
+ async with app.run_test() as pilot:
74
+ await pilot.pause()
75
+ await _press(pilot, "escape")
76
+ assert app.path == f, app.path
77
+ assert list(app.query("#editor"))
78
+
79
+
80
+ async def test_editor_escape_hidden_tree_clean_shows_quit_confirmation() -> None:
81
+ _, f, app = _file_app("editor-escape-clean.txt", "foo", root_is_tmp=True)
82
+ async with app.run_test() as pilot:
83
+ await pilot.pause()
84
+ await _press(pilot, "super+b")
85
+ await pilot.pause()
86
+ await _press(pilot, "escape")
87
+ assert isinstance(app.screen, mod.QuitConfirmationScreen)
88
+
89
+
90
+ async def test_editor_escape_hidden_tree_dirty_shows_unsaved_changes() -> None:
91
+ _, f, app = _file_app("editor-escape-dirty.txt", "orig", root_is_tmp=True)
92
+ async with app.run_test() as pilot:
93
+ await pilot.pause()
94
+ await _make_dirty(app, pilot)
95
+ await _press(pilot, "super+b")
96
+ await pilot.pause()
97
+ await _press(pilot, "escape")
98
+ assert isinstance(app.screen, mod.UnsavedChangesScreen)
99
+
100
+
71
101
  async def test_file_tree_escape_clean_shows_quit_confirmation_then_cancel() -> None:
72
102
  _, f, app = _file_app("tree-escape-clean.txt", "foo", root_is_tmp=True)
73
103
  async with app.run_test() as pilot:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes