use debug uri for relative paths; better fix for #61088
This commit is contained in:
parent
994eaadcb9
commit
cef0992fff
|
@ -56,20 +56,24 @@ export class DebugContentProvider implements IWorkbenchContribution, ITextModelC
|
|||
if (!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);
|
||||
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 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 modePromise = this.modeService.getOrCreateMode(mime);
|
||||
return this.modelService.createModel(response.body.content, modePromise, resource);
|
||||
}
|
||||
|
||||
const mime = response.body.mimeType || guessMimeTypes(resource.path)[0];
|
||||
const modePromise = this.modeService.getOrCreateMode(mime);
|
||||
return this.modelService.createModel(response.body.content, modePromise, resource);
|
||||
return createErrModel();
|
||||
|
||||
}, (err: DebugProtocol.ErrorResponse) => createErrModel(err.message));
|
||||
}
|
||||
|
|
|
@ -49,15 +49,16 @@ export class Source {
|
|||
if (this.raw.sourceReference > 0) {
|
||||
this.uri = uri.parse(`${DEBUG_SCHEME}:${encodeURIComponent(path)}?session=${encodeURIComponent(sessionId)}&ref=${this.raw.sourceReference}`);
|
||||
} else {
|
||||
if (isUri(path)) {
|
||||
if (isUri(path)) { // path looks like a uri
|
||||
this.uri = uri.parse(path);
|
||||
} else {
|
||||
// assume path
|
||||
// assume a filesystem path
|
||||
if (paths.isAbsolute_posix(path) || paths.isAbsolute_win32(path)) {
|
||||
this.uri = uri.file(path);
|
||||
} else {
|
||||
// path is relative: this is not supported but if it happens we create a bogus uri for backward compatibility
|
||||
this.uri = uri.file(path);
|
||||
// path is relative: since VS Code cannot deal with this by itself
|
||||
// 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)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue