Skip to content

Fix Vi visual block operator boundaries - #2172

Open
ViktorBystrov72 wants to merge 1 commit into
prompt-toolkit:mainfrom
ViktorBystrov72:fix/vi-block-delete
Open

ViktorBystrov72 wants to merge 1 commit into
prompt-toolkit:mainfrom
ViktorBystrov72:fix/vi-block-delete

Conversation

@ViktorBystrov72

Copy link
Copy Markdown

Fixes #1661.

In Vi visual-block mode, d, c, and y shift the upper selection endpoint one character left before cutting. At column zero this moves the endpoint onto the previous line, so an operator can remove whole intervening lines instead of the selected rectangle.

Only adjust the upper endpoint for characterwise text objects. Block selections keep their original corners, producing the intended remaining text and block clipboard contents.

Added 18 tests through the real PromptSession key-binding path: all three operators, upward/downward selection, multiple columns, a single character, and empty/short lines. All 18 fail on unmodified main and pass with the change.

Validation on Python 3.13.13:

python -m pytest tests/test_cli.py -k test_vi_visual_block_operators -q
coverage run -m pytest tests/
ruff check .
ruff format --check .
typos .
mypy --strict src/ --platform win32
mypy --strict src/ --platform linux
mypy --strict src/ --platform darwin
git diff --check

All passed. The full suite has 174 passing tests; each mypy run checked 145 source files. Runtime tests were run on macOS; the platform flags above are static checks.

OpenAI Codex assisted with the implementation, regression tests, and PR description. The reported checks were run locally; no human review is claimed.

Keep both corners of a visual block selection intact when converting it to clipboard data. Adjusting the upper endpoint as for characterwise ranges changes the selected columns and can omit the final row.
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.

vi mode: d deletes something other than the selected characters (block select)

1 participant