Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use selectionRange in edits when available #1429

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion vscode/src/non-stop/FixupController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ export class FixupController
}

/**
* This function retrieves a "smart" selection a FixupTask.
* This function retrieves a "smart" selection for a FixupTask when selectionRange is not available.
*
* The idea of a "smart" selection is to look at both the start and end positions of the current selection,
* and attempt to expand those positions to encompass more meaningful chunks of code, such as folding regions.
*
Expand All @@ -243,6 +244,11 @@ export class FixupController
const fileName = task.fixupFile.uri.fsPath
const documentUri = vscode.Uri.file(fileName)

// Use selectionRange when it's available
if (selectionRange && !selectionRange?.start.isEqual(selectionRange.end)) {
return selectionRange
}

// Retrieve the start position of the current selection
const activeCursorStartPosition = selectionRange.start
// If we find a new expanded selection position then we set it as the new start position
Expand Down