2026-10-11 02:36:23 +00:00
|
|
|
import * as vscode from 'vscode';
|
|
|
|
|
|
2026-10-27 22:38:30 +00:00
|
|
|
export class TabFix {
|
|
|
|
|
public diagnosticCode = 'invalid_tab';
|
2026-10-11 02:36:23 +00:00
|
|
|
|
|
|
|
|
public provideFix(document: vscode.TextDocument, diagnostic: vscode.Diagnostic): vscode.CodeAction[] {
|
2026-10-27 22:38:30 +00:00
|
|
|
const action = new vscode.CodeAction("Convert tabs to 4 spaces", vscode.CodeActionKind.QuickFix);
|
|
|
|
|
action.edit = new vscode.WorkspaceEdit();
|
2026-10-11 02:36:23 +00:00
|
|
|
|
|
|
|
|
const line = document.lineAt(diagnostic.range.start.line);
|
|
|
|
|
const newText = line.text.replace(/\t/g, ' ');
|
|
|
|
|
|
2026-10-27 22:38:30 +00:00
|
|
|
action.edit.replace(document.uri, line.range, newText);
|
|
|
|
|
action.diagnostics = [diagnostic];
|
|
|
|
|
action.isPreferred = true;
|
2026-10-11 02:36:23 +00:00
|
|
|
|
2026-10-27 22:38:30 +00:00
|
|
|
return [action];
|
2026-10-11 02:36:23 +00:00
|
|
|
}
|
2026-10-27 22:38:30 +00:00
|
|
|
}
|