Updated the editor
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
"use strict";
|
||||
|
||||
const vscode = require("vscode");
|
||||
const { formatWrn } = require("./formatter.js");
|
||||
const { formatWrn } = require("./formatter");
|
||||
|
||||
// The .wrn compiler, bundled to CJS by `bun run build:compiler`. Loaded
|
||||
// defensively so the rest of the extension (highlighting, snippets, completion)
|
||||
@@ -115,13 +115,17 @@ function activate(context) {
|
||||
context.subscriptions.push(
|
||||
vscode.languages.registerDocumentFormattingEditProvider("wrn", {
|
||||
provideDocumentFormattingEdits(document, options) {
|
||||
if (!vscode.workspace.getConfiguration("wrnexus").get("format.enable", true)) return [];
|
||||
const formatted = formatWrn(document.getText(), options);
|
||||
if (formatted === document.getText()) return [];
|
||||
const end = document.positionAt(document.getText().length);
|
||||
return [
|
||||
vscode.TextEdit.replace(new vscode.Range(new vscode.Position(0, 0), end), formatted),
|
||||
];
|
||||
const source = document.getText();
|
||||
|
||||
const formatted = formatWrn(source, {
|
||||
tabSize: options.tabSize,
|
||||
insertSpaces: options.insertSpaces,
|
||||
printWidth: 100,
|
||||
});
|
||||
|
||||
const range = new vscode.Range(document.positionAt(0), document.positionAt(source.length));
|
||||
|
||||
return [vscode.TextEdit.replace(range, formatted)];
|
||||
},
|
||||
}),
|
||||
vscode.languages.registerCompletionItemProvider(
|
||||
|
||||
Reference in New Issue
Block a user