Skip to content

fix: validate marks immediately after creation in visual selection#137

Open
funkybooboo wants to merge 1 commit intoThePrimeagen:masterfrom
funkybooboo:master
Open

fix: validate marks immediately after creation in visual selection#137
funkybooboo wants to merge 1 commit intoThePrimeagen:masterfrom
funkybooboo:master

Conversation

@funkybooboo
Copy link

Fixes crashes when marks are used before validation during visual selection operations.

Problem

The current code creates marks and immediately uses them for logging and RequestStatus before validating they were created successfully. When the buffer is modified between range calculation and mark creation, the marks fail to create but are still used, causing crashes.

Current flow:

  1. Create marks (may fail silently)
  2. Use marks for logging - crashes if invalid
  3. Pass marks to RequestStatus - crashes if invalid
  4. Start status updates - crashes if invalid
  5. Much later, in async callback, validate marks (too late)

Solution

Validate marks immediately after creation, before using them. This fails fast with a clear error message instead of crashing later with cryptic errors.

New flow:

  1. Create marks
  2. Validate marks immediately
  3. If invalid, log fatal error and return early
  4. If valid, proceed safely knowing marks are good

Benefits

  • Fails fast with clear error message
  • No defensive nil checks needed throughout codebase
  • Single validation point instead of scattered checks
  • Prevents crashes in logging, RequestStatus, and status updates
  • Better user experience with actionable error message

Testing

  • All existing tests pass (68/68)
  • Linting passes
  • Formatting passes
  • Follows existing error handling patterns in the codebase

@cursor
Copy link

cursor bot commented Feb 24, 2026

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on March 8.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Moves mark validation from async on_complete callback to immediately
after mark creation. This prevents crashes when marks are used for
logging or passed to RequestStatus before validation occurs.

Fails fast with clear error message if buffer has been modified and
marks cannot be created, rather than crashing later with cryptic errors.
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.

1 participant