mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-23 17:23:02 -05:00
Merge from vscode 718331d6f3ebd1b571530ab499edb266ddd493d5
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { URI as uri } from 'vs/base/common/uri';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { normalize, isAbsolute } from 'vs/base/common/path';
|
||||
import * as resources from 'vs/base/common/resources';
|
||||
import { DEBUG_SCHEME } from 'vs/workbench/contrib/debug/common/debug';
|
||||
@@ -13,6 +13,7 @@ import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { isUri } from 'vs/workbench/contrib/debug/common/debugUtils';
|
||||
import { ITextEditor } from 'vs/workbench/common/editor';
|
||||
import { TextEditorSelectionRevealType } from 'vs/platform/editor/common/editor';
|
||||
|
||||
export const UNKNOWN_SOURCE_LABEL = nls.localize('unknownSource', "Unknown Source");
|
||||
|
||||
@@ -31,7 +32,7 @@ export const UNKNOWN_SOURCE_LABEL = nls.localize('unknownSource', "Unknown Sourc
|
||||
|
||||
export class Source {
|
||||
|
||||
readonly uri: uri;
|
||||
readonly uri: URI;
|
||||
available: boolean;
|
||||
raw: DebugProtocol.Source;
|
||||
|
||||
@@ -47,30 +48,7 @@ export class Source {
|
||||
path = `${DEBUG_SCHEME}:${UNKNOWN_SOURCE_LABEL}`;
|
||||
}
|
||||
|
||||
if (typeof this.raw.sourceReference === 'number' && this.raw.sourceReference > 0) {
|
||||
this.uri = uri.from({
|
||||
scheme: DEBUG_SCHEME,
|
||||
path,
|
||||
query: `session=${sessionId}&ref=${this.raw.sourceReference}`
|
||||
});
|
||||
} else {
|
||||
if (isUri(path)) { // path looks like a uri
|
||||
this.uri = uri.parse(path);
|
||||
} else {
|
||||
// assume a filesystem path
|
||||
if (isAbsolute(path)) {
|
||||
this.uri = uri.file(path);
|
||||
} else {
|
||||
// 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.from({
|
||||
scheme: DEBUG_SCHEME,
|
||||
path,
|
||||
query: `session=${sessionId}`
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
this.uri = getUriFromSource(this.raw, path, sessionId);
|
||||
}
|
||||
|
||||
get name() {
|
||||
@@ -95,19 +73,19 @@ export class Source {
|
||||
|
||||
openInEditor(editorService: IEditorService, selection: IRange, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise<ITextEditor | undefined> {
|
||||
return !this.available ? Promise.resolve(undefined) : editorService.openEditor({
|
||||
resource: this.uri,
|
||||
resource: this.uri.with({ query: null }),
|
||||
description: this.origin,
|
||||
options: {
|
||||
preserveFocus,
|
||||
selection,
|
||||
revealIfOpened: true,
|
||||
revealInCenterIfOutsideViewport: true,
|
||||
selectionRevealType: TextEditorSelectionRevealType.CenterIfOutsideViewport,
|
||||
pinned: pinned || (!preserveFocus && !this.inMemory)
|
||||
}
|
||||
}, sideBySide ? SIDE_GROUP : ACTIVE_GROUP);
|
||||
}
|
||||
|
||||
static getEncodedDebugData(modelUri: uri): { name: string, path: string, sessionId?: string, sourceReference?: number } {
|
||||
static getEncodedDebugData(modelUri: URI): { name: string, path: string, sessionId?: string, sourceReference?: number } {
|
||||
let path: string;
|
||||
let sourceReference: number | undefined;
|
||||
let sessionId: string | undefined;
|
||||
@@ -148,3 +126,28 @@ export class Source {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function getUriFromSource(raw: DebugProtocol.Source, path: string | undefined, sessionId: string): URI {
|
||||
if (typeof raw.sourceReference === 'number' && raw.sourceReference > 0) {
|
||||
return URI.from({
|
||||
scheme: DEBUG_SCHEME,
|
||||
path,
|
||||
query: `session=${sessionId}&ref=${raw.sourceReference}`
|
||||
});
|
||||
}
|
||||
|
||||
if (path && isUri(path)) { // path looks like a uri
|
||||
return URI.parse(path);
|
||||
}
|
||||
// assume a filesystem path
|
||||
if (path && isAbsolute(path)) {
|
||||
return 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.
|
||||
return URI.from({
|
||||
scheme: DEBUG_SCHEME,
|
||||
path,
|
||||
query: `session=${sessionId}`
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user