sketch for virtual document support for

This commit is contained in:
Jan Kretschmer
2021-11-01 14:50:32 +01:00
parent c2f44d476b
commit b074018c3e
3 changed files with 40 additions and 10 deletions

View File

@@ -26,6 +26,13 @@ export function getCustomDataSource(toDispose: Disposable[]) {
}
}));
toDispose.push(workspace.onDidChangeTextDocument(e => {
const path = e.document.uri.toString();
if (pathsInExtensions.indexOf(path) || pathsInWorkspace.indexOf(path)) {
onChange.fire();
}
}));
return {
get uris() {
return pathsInWorkspace.concat(pathsInExtensions);
@@ -50,7 +57,14 @@ function getCustomDataPathsInAllWorkspaces(): string[] {
if (Array.isArray(paths)) {
for (const path of paths) {
if (typeof path === 'string') {
dataPaths.push(resolvePath(rootFolder, path).toString());
const uri = Uri.parse(path);
if (uri.scheme === 'file') {
// only resolve file paths relative to extension
dataPaths.push(resolvePath(rootFolder, path).toString());
} else {
// others schemes
dataPaths.push(path);
}
}
}
}
@@ -80,7 +94,15 @@ function getCustomDataPathsFromAllExtensions(): string[] {
const customData = extension.packageJSON?.contributes?.html?.customData;
if (Array.isArray(customData)) {
for (const rp of customData) {
dataPaths.push(joinPath(extension.extensionUri, rp).toString());
const uri = Uri.parse(rp);
if (uri.scheme === 'file') {
// only resolve file paths relative to extension
dataPaths.push(joinPath(extension.extensionUri, rp).toString());
} else {
// others schemes
dataPaths.push(rp);
}
}
}
}