Skip to content

Commit 0ef361c

Browse files
authored
🔀 Merge pull request #133 from davep/toc-mismatch
Try and keep the ToC in sync
2 parents f231cf3 + 2692fed commit 0ef361c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

ChangeLog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Hike ChangeLog
22

3+
## Unreleased
4+
5+
**Released: WiP**
6+
7+
- Fixed a problem with the ToC getting out of sync in some circumstances.
8+
([#132](https://github.com/davep/hike/issues/132))
9+
310
## v1.1.3
411

512
**Released: 2025-08-19**

src/hike/widgets/viewer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,22 +354,23 @@ def _watch_location(self) -> None:
354354
self._visit(self.location)
355355

356356
@on(Loaded)
357-
def _update_markdown(self, message: Loaded) -> None:
357+
async def _update_markdown(self, message: Loaded) -> None:
358358
"""Update the markdown once some new content is loaded.
359359
360360
Args:
361361
message: The message requesting the update.
362362
"""
363363
self.query_one(ViewerTitle).location = self.location
364364
self._source = message.markdown
365-
self.query_one(Markdown).update(message.markdown)
365+
await self.query_one(Markdown).update(message.markdown)
366366
if (
367367
message.remember
368368
and self.location
369369
and self.location != self.history.current_item
370370
):
371371
self.history.add(self.location)
372-
self.post_message(self.HistoryUpdated(self))
372+
if self.parent is not None:
373+
self.parent.post_message(self.HistoryUpdated(self))
373374

374375
def _visit_from_history(self) -> None:
375376
"""Visit the current location in history."""

0 commit comments

Comments
 (0)