Add MD server tracing and update diagnostics on files changes (#155797)

This commit is contained in:
Matt Bierner 2022-07-21 10:07:06 -07:00 committed by GitHub
parent 9c413ba105
commit b2daf1af82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 34 additions and 13 deletions

View file

@ -398,16 +398,27 @@
"description": "%configuration.markdown.suggest.paths.enabled.description%",
"scope": "resource"
},
"markdown.trace": {
"markdown.trace.extension": {
"type": "string",
"enum": [
"off",
"verbose"
],
"default": "off",
"description": "%markdown.trace.desc%",
"description": "%markdown.trace.extension.desc%",
"scope": "window"
},
"markdown.trace.server": {
"type": "string",
"scope": "window",
"enum": [
"off",
"messages",
"verbose"
],
"default": "off",
"description": "%markdown.trace.server.desc%"
},
"markdown.editor.drop.enabled": {
"type": "boolean",
"default": true,

View file

@ -17,7 +17,8 @@
"markdown.showSource.title": "Show Source",
"markdown.styles.dec": "A list of URLs or local paths to CSS style sheets to use from the Markdown preview. Relative paths are interpreted relative to the folder open in the Explorer. If there is no open folder, they are interpreted relative to the location of the Markdown file. All '\\' need to be written as '\\\\'.",
"markdown.showPreviewSecuritySelector.title": "Change Preview Security Settings",
"markdown.trace.desc": "Enable debug logging for the Markdown extension.",
"markdown.trace.extension.desc": "Enable debug logging for the Markdown extension.",
"markdown.trace.server.desc": "Traces the communication between VS Code and the Markdown language server.",
"markdown.preview.refresh.title": "Refresh Preview",
"markdown.preview.toggleLock.title": "Toggle Preview Locking",
"markdown.findAllFileReferences": "Find File References",

View file

@ -13,7 +13,7 @@
"vscode-languageserver": "^8.0.2-next.5`",
"vscode-languageserver-textdocument": "^1.0.5",
"vscode-languageserver-types": "^3.17.1",
"vscode-markdown-languageservice": "^0.0.0-alpha.10",
"vscode-markdown-languageservice": "^0.0.0-alpha.11",
"vscode-uri": "^3.0.3"
},
"devDependencies": {

View file

@ -5,6 +5,7 @@
import { Connection, FullDocumentDiagnosticReport, UnchangedDocumentDiagnosticReport } from 'vscode-languageserver';
import * as md from 'vscode-markdown-languageservice';
import { disposeAll } from 'vscode-markdown-languageservice/out/util/dispose';
import { Disposable } from 'vscode-notebook-renderer/events';
import { URI } from 'vscode-uri';
import { ConfigurationManager, ValidateEnabled } from '../configuration';
@ -53,7 +54,15 @@ export function registerValidateSupport(
diagnosticOptions = getDiagnosticsOptions(config);
}
const subs: Disposable[] = [];
const manager = ls.createPullDiagnosticsManager();
subs.push(manager);
subs.push(manager.onLinkedToFileChanged(() => {
// TODO: We only need to refresh certain files
connection.languages.diagnostics.refresh();
}));
connection.languages.diagnostics.on(async (params, token): Promise<FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport> => {
if (!config.getSettings()?.markdown.experimental.validate.enabled) {
@ -73,14 +82,14 @@ export function registerValidateSupport(
});
updateDiagnosticsSetting();
const configChangeSub = config.onDidChangeConfiguration(() => {
subs.push(config.onDidChangeConfiguration(() => {
updateDiagnosticsSetting();
connection.languages.diagnostics.refresh();
});
}));
return {
dispose: () => {
manager.dispose();
configChangeSub.dispose();
disposeAll(subs);
}
};
}

View file

@ -47,10 +47,10 @@ vscode-languageserver@^8.0.2-next.5`:
dependencies:
vscode-languageserver-protocol "3.17.2-next.6"
vscode-markdown-languageservice@^0.0.0-alpha.10:
version "0.0.0-alpha.10"
resolved "https://registry.yarnpkg.com/vscode-markdown-languageservice/-/vscode-markdown-languageservice-0.0.0-alpha.10.tgz#53b69c981eed7fd5efa155ab8c0f169995568681"
integrity sha512-rJ85nJ+d45yCz9lBhipavoWXz/vW5FknqqUpLqhe3/2xkrhxt8zcekhSoDepgkKFcTORAFV6g1SnnqxbVhX+uA==
vscode-markdown-languageservice@^0.0.0-alpha.11:
version "0.0.0-alpha.11"
resolved "https://registry.yarnpkg.com/vscode-markdown-languageservice/-/vscode-markdown-languageservice-0.0.0-alpha.11.tgz#9dcdfc23f9dcaeaca3b2a2c76fc504619eaeb284"
integrity sha512-syFamf99xx+Q9DkA66+8fbSz2A2LJkyOV+nSziGgAzdDPv4jkb7eWF6l+nUteHTGbRLQ+q0tfkj0A7OovueCSQ==
dependencies:
picomatch "^2.3.1"
vscode-languageserver-textdocument "^1.0.5"

View file

@ -70,7 +70,7 @@ export class VsCodeOutputLogger extends Disposable implements ILogger {
}
private readTrace(): Trace {
return Trace.fromString(vscode.workspace.getConfiguration().get<string>('markdown.trace', 'off'));
return Trace.fromString(vscode.workspace.getConfiguration().get<string>('markdown.trace.extension', 'off'));
}
private static data2String(data: any): string {