diff --git a/src/features/formatters/ruff.ts b/src/features/formatters/ruff.ts index 5d157fb..ca01890 100644 --- a/src/features/formatters/ruff.ts +++ b/src/features/formatters/ruff.ts @@ -25,17 +25,10 @@ export class RuffFormatter extends BaseFormatter { token: CancellationToken, range?: Range, ): Thenable { + 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); }