Skip to content

feat(frontend): Expand/Shrink Selection via tree-sitter AST (Shift+Alt+Right/Left)#84

Merged
KrisPowers merged 2 commits into
masterfrom
feat/smart-select
Jun 30, 2026
Merged

feat(frontend): Expand/Shrink Selection via tree-sitter AST (Shift+Alt+Right/Left)#84
KrisPowers merged 2 commits into
masterfrom
feat/smart-select

Conversation

@KrisPowers

Copy link
Copy Markdown
Member

Summary

  • Adds editor.smartSelect IPC op to the C++ backend (editor_buffer.cpp) that walks the tree-sitter parse tree from the current selection upward, returning the byte range of the smallest named node that strictly contains the selection
  • GpuEditor gains expandSmartSelect / shrinkSmartSelect on its imperative handle, with a history stack so each Shrink reverses the last Expand step; history clears on any regular cursor movement
  • FullscreenIDE wires editor.action.smartSelect.expand and editor.action.smartSelect.shrink into the trigger handler, enabling the Edit menu items that were previously no-ops
  • Shift+Alt+Right / Shift+Alt+Left are also handled directly in the GpuEditor keydown handler so the shortcuts work without going through the menu

Works for all tree-sitter-backed languages (JS, TS, TSX, Python, C, C++, Rust, Go, Java, and more). Falls back to a no-op for unsupported files with no parse tree.

Test plan

  • Open a JS/TS file, place cursor inside a string literal, press Shift+Alt+Right: selects string content, then full string with quotes, then surrounding expression, then statement, then block, and so on to file root
  • Shift+Alt+Left reverses each step
  • Edit menu Expand Selection / Shrink Selection items produce the same result as the keyboard shortcut
  • Regular cursor movement (arrow keys, click) clears the expand history so shrink becomes a no-op
  • Opening a plain-text file with no tree-sitter grammar: Shift+Alt+Right is a no-op, no error
  • Verify in Python, C++, and Rust files as well

Closes #71

@KrisPowers KrisPowers changed the title feat(editor): Expand/Shrink Selection via tree-sitter AST (Shift+Alt+Right/Left) feat(frontend): Expand/Shrink Selection via tree-sitter AST (Shift+Alt+Right/Left) Jun 30, 2026
Adds editor.smartSelect IPC op to the C++ backend that walks the
tree-sitter parse tree upward from the current selection to find the
smallest named node that strictly contains it.

Frontend wires Shift+Alt+Right/Left in GpuEditor and the Edit menu
commands (editor.action.smartSelect.expand/shrink) in FullscreenIDE.
A history stack on the editor enables shrink to reverse each expand
step. Works for all tree-sitter-backed languages; falls back to no-op
for unsupported files.

Closes #71
Ctrl/Cmd+Click toggles items in the selection; Shift+Click selects a
contiguous range from the last-clicked anchor. Selected items render with
an accent-tinted highlight distinct from the single active-file highlight.

Right-clicking a multi-selection shows a batch context menu (Delete
Selected, Copy Paths). Delete/Backspace fires the confirmation dialog for
all selected items, which now accepts an array and reports the count when
multiple targets are involved. Dragging a selection moves all selected
files to the drop folder in parallel. Escape clears the selection.

Closes #73
@KrisPowers KrisPowers merged commit 5ae1572 into master Jun 30, 2026
24 checks passed
@KrisPowers KrisPowers deleted the feat/smart-select branch June 30, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editor: Expand and Shrink Selection (Shift+Alt+Right/Left) are no-ops

1 participant