Fix Ctrl+V Visual Block not entering with empty clipboard #3

Merged
daniel merged 1 commit from fix/ctrl-v-visual-block into main 2026-11-19 09:09:08 +00:00
Collaborator

Problem

Ctrl+V only entered Visual Block mode when the clipboard held text. With an empty clipboard, or with an image or files copied, it did nothing.

Cause

egui-winit treats Ctrl+V as a paste shortcut (egui-winit-0.31.1/src/lib.rs:772-779):

  • If the clipboard holds non-empty text, the press is sent as Event::Paste. The editor already handled this.
  • If the clipboard is empty or holds non-text data, the press is dropped. Only the Key::V release reaches the app, and the editor ignored releases.

The editor's own Ctrl+V key handler is never reached in the real app. The old test called handle_key_press(Key::V, ctrl) directly, so it passed even though the app was broken.

Fix

  • Moved the editor's event loop out of ui() into a new VimSqlEditor::handle_input_event method that tests can call.
  • A V release with no matching press event now counts as Ctrl+V. This also works when Ctrl is released before V.
  • Visual Block now toggles once per physical press, so holding Ctrl+V no longer flips the mode on every repeated Paste event.
  • The Ctrl+V tracking is reset when the editor loses focus, and on Insert release (Shift+Insert also produces Paste).
  • Added tests that replay the real egui-winit event sequences: empty clipboard, text clipboard with repeats, plain v, and paste in Insert mode.

Testing

cargo test passes (15 tests). Not yet tried in the Windows GUI.

🤖 Generated with Claude Code

## Problem Ctrl+V only entered Visual Block mode when the clipboard held text. With an empty clipboard, or with an image or files copied, it did nothing. ## Cause egui-winit treats Ctrl+V as a paste shortcut (`egui-winit-0.31.1/src/lib.rs:772-779`): - If the clipboard holds non-empty text, the press is sent as `Event::Paste`. The editor already handled this. - If the clipboard is empty or holds non-text data, the press is dropped. Only the `Key::V` **release** reaches the app, and the editor ignored releases. The editor's own Ctrl+V key handler is never reached in the real app. The old test called `handle_key_press(Key::V, ctrl)` directly, so it passed even though the app was broken. ## Fix - Moved the editor's event loop out of `ui()` into a new `VimSqlEditor::handle_input_event` method that tests can call. - A V release with no matching press event now counts as Ctrl+V. This also works when Ctrl is released before V. - Visual Block now toggles once per physical press, so holding Ctrl+V no longer flips the mode on every repeated `Paste` event. - The Ctrl+V tracking is reset when the editor loses focus, and on Insert release (Shift+Insert also produces `Paste`). - Added tests that replay the real egui-winit event sequences: empty clipboard, text clipboard with repeats, plain `v`, and paste in Insert mode. ## Testing `cargo test` passes (15 tests). Not yet tried in the Windows GUI. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
egui-winit turns a Ctrl+V press into Event::Paste when the clipboard
holds text, and drops the press entirely when the clipboard is empty or
holds non-text data, so only the key release reached the editor. Treat
a V release without a matching press as Ctrl+V, toggle only once per
physical press (Paste auto-repeat no longer flickers the mode), and move
event handling into a testable handle_input_event method with tests
replaying the real egui-winit event sequences.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
daniel merged commit 42cff81d06 into main 2026-11-19 09:09:08 +00:00
daniel deleted branch fix/ctrl-v-visual-block 2026-11-19 09:09:13 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
daniel/qry-duck!3
No description provided.