提交 cef0992f 编写于 作者: A Andre Weinand

use debug uri for relative paths; better fix for #61088

上级 994eaadc
...@@ -56,20 +56,24 @@ export class DebugContentProvider implements IWorkbenchContribution, ITextModelC ...@@ -56,20 +56,24 @@ export class DebugContentProvider implements IWorkbenchContribution, ITextModelC
if (!session) { if (!session) {
return Promise.reject(new Error(localize('unable', "Unable to resolve the resource without a debug session"))); return Promise.reject(new Error(localize('unable', "Unable to resolve the resource without a debug session")));
} }
const createErrModel = (message: string) => { const createErrModel = (errMsg?: string) => {
this.debugService.sourceIsNotAvailable(resource); this.debugService.sourceIsNotAvailable(resource);
const modePromise = this.modeService.getOrCreateMode(MIME_TEXT); const modePromise = this.modeService.getOrCreateMode(MIME_TEXT);
const message = errMsg
? localize('canNotResolveSourceWithError', "Could not load source '{0}': {1}.", resource.path, errMsg)
: localize('canNotResolveSource', "Could not load source '{0}'.", resource.path);
return this.modelService.createModel(message, modePromise, resource); return this.modelService.createModel(message, modePromise, resource);
}; };
return session.loadSource(resource).then(response => { return session.loadSource(resource).then(response => {
if (!response) {
return createErrModel(localize('canNotResolveSource', "Could not resolve resource {0}, no response from debug extension.", resource.toString()));
}
if (response && response.body) {
const mime = response.body.mimeType || guessMimeTypes(resource.path)[0]; const mime = response.body.mimeType || guessMimeTypes(resource.path)[0];
const modePromise = this.modeService.getOrCreateMode(mime); const modePromise = this.modeService.getOrCreateMode(mime);
return this.modelService.createModel(response.body.content, modePromise, resource); return this.modelService.createModel(response.body.content, modePromise, resource);
}
return createErrModel();
}, (err: DebugProtocol.ErrorResponse) => createErrModel(err.message)); }, (err: DebugProtocol.ErrorResponse) => createErrModel(err.message));
} }
......
...@@ -49,15 +49,16 @@ export class Source { ...@@ -49,15 +49,16 @@ export class Source {
if (this.raw.sourceReference > 0) { if (this.raw.sourceReference > 0) {
this.uri = uri.parse(`${DEBUG_SCHEME}:${encodeURIComponent(path)}?session=${encodeURIComponent(sessionId)}&ref=${this.raw.sourceReference}`); this.uri = uri.parse(`${DEBUG_SCHEME}:${encodeURIComponent(path)}?session=${encodeURIComponent(sessionId)}&ref=${this.raw.sourceReference}`);
} else { } else {
if (isUri(path)) { if (isUri(path)) { // path looks like a uri
this.uri = uri.parse(path); this.uri = uri.parse(path);
} else { } else {
// assume path // assume a filesystem path
if (paths.isAbsolute_posix(path) || paths.isAbsolute_win32(path)) { if (paths.isAbsolute_posix(path) || paths.isAbsolute_win32(path)) {
this.uri = uri.file(path); this.uri = uri.file(path);
} else { } else {
// path is relative: this is not supported but if it happens we create a bogus uri for backward compatibility // path is relative: since VS Code cannot deal with this by itself
this.uri = uri.file(path); // create a debug url that will result in a DAP 'source' request when the url is resolved.
this.uri = uri.parse(`${DEBUG_SCHEME}:${encodeURIComponent(path)}?session=${encodeURIComponent(sessionId)}`);
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册