Skip to content

Commit

Permalink
hook git decorations up to explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
danprince committed Jul 7, 2022
1 parent ad8b78d commit f2e5c2b
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions extension.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
let assert = require("node:assert");
let path = require("node:path");
let { homedir } = require("node:os");
let { window, workspace, commands, Uri, EventEmitter, FileType, Selection, languages, Range, Diagnostic, DiagnosticRelatedInformation, Location } = require("vscode");
let { window, workspace, commands, Uri, EventEmitter, FileType, Selection, languages, Range, Diagnostic, DiagnosticRelatedInformation, Location, extensions, ThemeColor } = require("vscode");
let gitDecorations = require("./git-decorations");

/**
* The scheme is used to associate vsnetrw documents with the text content provider
Expand Down Expand Up @@ -136,6 +137,7 @@ async function openExplorer(dirName) {
await languages.setTextDocumentLanguage(doc, languageId);
restoreSelections();
refreshDiagnostics();
gitDecorations.updateDecorations();
refresh();
}

Expand Down Expand Up @@ -384,14 +386,6 @@ async function provideTextDocumentContent(documentUri) {
return listings.join("\n");
}

/**
* @type {import("vscode").TextDocumentContentProvider}
*/
let contentProvider = {
onDidChange: uriChangeEmitter.event,
provideTextDocumentContent,
};

let diagnostics = languages.createDiagnosticCollection("vsnetrw");

/**
Expand All @@ -415,10 +409,10 @@ function refreshDiagnostics() {
let severities = childDiagnostics.map(diagnostic => diagnostic.severity);
let severity = Math.min(...severities);
let name = path.basename(uri.fsPath);
let range = new Range(line, 0, line, name.length);

let diagnostic = new Diagnostic(
range, `${childDiagnostics.length} problems in this file`,
new Range(line, 0, line, name.length),
`${childDiagnostics.length} problems in this file`,
severity
);

Expand All @@ -435,6 +429,14 @@ function refreshDiagnostics() {
diagnostics.set(document.uri, ownDiagnostics);
}

/**
* @type {import("vscode").TextDocumentContentProvider}
*/
let contentProvider = {
onDidChange: uriChangeEmitter.event,
provideTextDocumentContent,
};

/**
* @param {import("vscode").ExtensionContext} context
*/
Expand Down

0 comments on commit f2e5c2b

Please # to comment.