Skip to content

Commit

Permalink
feat: add range argument to Ruff formatter. (#1100)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordan-turbofish authored Aug 26, 2024
1 parent 678e9e7 commit c6afd14
Showing 1 changed file with 2 additions and 9 deletions.
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

0 comments on commit c6afd14

Please sign in to comment.