Skip to content

Fix autocomplete crash from stale cursor locations#16

Merged
koianaoki merged 1 commit into
codex/fix-filter-issue-in-tree-viewfrom
codex/fix-autocomplete-error-in-mixins
May 19, 2026
Merged

Fix autocomplete crash from stale cursor locations#16
koianaoki merged 1 commit into
codex/fix-filter-issue-in-tree-viewfrom
codex/fix-autocomplete-error-in-mixins

Conversation

@koianaoki
Copy link
Copy Markdown
Owner

Motivation

  • Prevent crashes when debounced autocomplete callbacks run with a stale TextArea.cursor_location that can contain a row beyond the current document, which previously could index past available lines.
  • Ensure conversions between (row, col) and offset always produce values clamped to the current document bounds.

Description

  • Update _location_to_offset to clamp stale or out-of-range row and col values to the current text content so it cannot index past available lines.
  • Clamp offset inside _offset_to_location to the valid 0..len(text) range before computing (row, col).
  • Add regression tests in tests/unit/test_autocomplete_location.py that cover a stale row beyond the last line, an overlong column, and out-of-range offsets.

Testing

  • Ran pytest tests/unit/test_autocomplete_location.py -q in the environment where textual was not installed and collection failed with ModuleNotFoundError (expected in that environment).
  • Ran uv run pytest tests/unit/test_autocomplete_location.py -q which executed the new tests and reported 3 passed.
  • Ran uv run ruff check sqlit/domains/query/ui/mixins/autocomplete.py tests/unit/test_autocomplete_location.py which completed with no linting issues.

Codex Task

@koianaoki
Copy link
Copy Markdown
Owner Author

@codex 日本語でレビューして

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@koianaoki koianaoki merged commit 1d809db into codex/fix-filter-issue-in-tree-view May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant