Skip to content

Commit

Permalink
Merge branch 'main' into flaky-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns authored Oct 17, 2023
2 parents 5238dd9 + 3b170b0 commit 7674b4f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed `Input.cursor_blink` reactive not changing blink state after `Input` was mounted https://github.com/Textualize/textual/pull/3498
- Fixed `Tabs.active` attribute value not being re-assigned after removing a tab or clearing https://github.com/Textualize/textual/pull/3498
- Fixed `DirectoryTree` race-condition crash when changing path https://github.com/Textualize/textual/pull/3498
- Fixed issue with LRUCache.discard https://github.com/Textualize/textual/issues/3537
- Fixed issue with `LRUCache.discard` https://github.com/Textualize/textual/issues/3537
- Fixed `DataTable` not scrolling to rows that were just added https://github.com/Textualize/textual/pull/3552
- Fixed cache bug with `DataTable.update_cell` https://github.com/Textualize/textual/pull/3551

### Changed

Expand Down
12 changes: 9 additions & 3 deletions src/textual/widgets/_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,9 +1116,10 @@ def move_cursor(
cursor_row = row
if column is not None:
cursor_column = column

destination = Coordinate(cursor_row, cursor_column)
self.cursor_coordinate = destination
self._scroll_cursor_into_view(animate=animate)
self.call_after_refresh(self._scroll_cursor_into_view, animate=animate)

def _highlight_coordinate(self, coordinate: Coordinate) -> None:
"""Apply highlighting to the cell at the coordinate, and post event."""
Expand Down Expand Up @@ -1230,6 +1231,7 @@ def _update_column_widths(self, updated_cells: set[CellKey]) -> None:
column = self.columns.get(column_key)
if column is None:
continue

console = self.app.console
label_width = measure(console, column.label, 1)
content_width = column.content_width
Expand Down Expand Up @@ -1287,6 +1289,8 @@ def _update_dimensions(self, new_rows: Iterable[RowKey]) -> None:
if row.auto_height:
auto_height_rows.append((row_index, row, cells_in_row))

self._clear_caches()

# If there are rows that need to have their height computed, render them correctly
# so that we can cache this rendering for later.
if auto_height_rows:
Expand Down Expand Up @@ -1612,9 +1616,11 @@ def remove_row(self, row_key: RowKey | str) -> None:
Raises:
RowDoesNotExist: If the row key does not exist.
"""

if row_key not in self._row_locations:
raise RowDoesNotExist(f"Row key {row_key!r} is not valid.")

self._new_rows.discard(row_key)
self._require_update_dimensions = True
self.check_idle()

Expand Down Expand Up @@ -1690,9 +1696,9 @@ async def _on_idle(self, _: events.Idle) -> None:
if self._updated_cells:
# Cell contents have already been updated at this point.
# Now we only need to worry about measuring column widths.
updated_columns = self._updated_cells.copy()
updated_cells = self._updated_cells.copy()
self._updated_cells.clear()
self._update_column_widths(updated_columns)
self._update_column_widths(updated_cells)

if self._require_update_dimensions:
# Add the new rows *before* updating the column widths, since
Expand Down

0 comments on commit 7674b4f

Please sign in to comment.