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

Add range argument to Ruff formatter. #1100

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
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
11 changes: 2 additions & 9 deletions src/features/formatters/ruff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,10 @@ export class RuffFormatter extends BaseFormatter {
token: CancellationToken,
range?: Range,
): Thenable<TextEdit[]> {
const ruffArgs = ['format', '--diff', '--silent'];
if (range) {
const errorMessage = async () => {
this.outputChannel.appendLine('Ruff does not support the "Format Selection" command');
window.showErrorMessage('Ruff does not support the "Format Selection" command');
return [] as TextEdit[];
};

return errorMessage();
ruffArgs.push(`--range=${range.start.line + 1}-${range.end.line}`);
}

const ruffArgs = ['format', '--diff', '--silent'];
if (this.pythonSettings.formatting.ruffArgs.length > 0) {
ruffArgs.push(...this.pythonSettings.formatting.ruffArgs);
}
Expand Down
Loading