Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
const editor = vscode.window.activeTextEditor;
if (editor && fixInfo) {
const document = editor.document;
const lineNumber = fixInfo.lineNumber || (lineIndex + 1);
const {text, range} = document.lineAt(lineNumber - 1);
const fixedText = markdownlintRuleHelpers.applyFix(text, fixInfo, "\n");
return editor.edit((editBuilder) => {
if (typeof fixedText === "string") {
editBuilder.replace(range, fixedText);
} else {
let deleteRange = range;
if (lineNumber === 1) {
if (document.lineCount > 1) {
const nextLine = document.lineAt(range.end.line + 1);
deleteRange = range.with({"end": nextLine.range.start});
}
} else {
const previousLine = document.lineAt(range.start.line - 1);
deleteRange = range.with({"start": previousLine.range.end});
}
editBuilder.delete(deleteRange);
}