Skip to content

Commit

Permalink
fix #485: avoid crash due to duplicate screen id (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
zqianem authored Mar 27, 2024
1 parent 67b7229 commit 4de48ee
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Bug Fixes

- Pressing `F8` on the history screen no longer causes a crash ([#485](https://github.com/tconbeer/harlequin/issues/485))

## [1.16.0] - 2024-02-22

### Changes
Expand Down
2 changes: 1 addition & 1 deletion src/harlequin/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ async def history_callback(screen_data: str) -> None:
"Please wait a moment and try again."
),
)
else:
elif self.screen.id != "history_screen":
self.push_screen(
HistoryScreen(
history=self.history,
Expand Down
20 changes: 20 additions & 0 deletions tests/functional_tests/test_history_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,23 @@ async def test_history_screen(
snap_results.append(await app_snapshot(app, "New buffer with select 14"))

assert all(snap_results)


@pytest.mark.asyncio
async def test_history_screen_crash(
app: Harlequin,
app_snapshot: Callable[..., Awaitable[bool]],
mock_time: None,
) -> None:
async with app.run_test() as pilot:
q = "\n".join([f"select {i};" for i in range(15)])
while app.editor is None:
await pilot.pause()
app.post_message(QuerySubmitted(query_text=q, limit=None))
await pilot.pause()
await app.workers.wait_for_complete()
await pilot.pause()

# https://github.com/tconbeer/harlequin/issues/485
await pilot.press("f8")
await pilot.press("f8")

0 comments on commit 4de48ee

Please sign in to comment.