From 98d4bd4bdbfec345e298842e9843cc82d294ce5f Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Fri, 2 Sep 2016 15:39:42 +0200 Subject: [PATCH 1/2] use nicer syntax for optional methods, #11203 --- src/vs/vscode.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 7d59d43ae88..01f0c73e0e4 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -1434,7 +1434,7 @@ declare namespace vscode { * @return A human readable string which is presented as diagnostic message. * Return `undefined`, `null`, or the empty string when 'value' is valid. */ - validateInput?: (value: string) => string; + validateInput?(value: string): string; } /** @@ -1843,7 +1843,7 @@ declare namespace vscode { * @return The resolved symbol or a thenable that resolves to that. When no result is returned, * the given `symbol` is used. */ - resolveWorkspaceSymbol?: (symbol: SymbolInformation, token: CancellationToken) => SymbolInformation | Thenable; + resolveWorkspaceSymbol?(symbol: SymbolInformation, token: CancellationToken): SymbolInformation | Thenable; } /** @@ -2445,7 +2445,7 @@ declare namespace vscode { * @param link The link that is to be resolved. * @param token A cancellation token. */ - resolveDocumentLink?: (link: DocumentLink, token: CancellationToken) => DocumentLink | Thenable; + resolveDocumentLink?(link: DocumentLink, token: CancellationToken): DocumentLink | Thenable; } /** From e334494baa1639f576477feb217e5163a9383643 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Fri, 2 Sep 2016 18:18:27 +0200 Subject: [PATCH 2/2] handle edge case, fixes #11402 --- src/vs/workbench/api/node/extHostWorkspace.ts | 2 +- .../workbench/test/node/api/extHostWorkspace.test.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/api/node/extHostWorkspace.ts b/src/vs/workbench/api/node/extHostWorkspace.ts index 11e5fdeec1b..c7e98adbe7e 100644 --- a/src/vs/workbench/api/node/extHostWorkspace.ts +++ b/src/vs/workbench/api/node/extHostWorkspace.ts @@ -39,7 +39,7 @@ export class ExtHostWorkspace { } if (isEqualOrParent(path, this._workspacePath)) { - return relative(this._workspacePath, path); + return relative(this._workspacePath, path) || path; } return path; diff --git a/src/vs/workbench/test/node/api/extHostWorkspace.test.ts b/src/vs/workbench/test/node/api/extHostWorkspace.test.ts index d9aece2b3a4..1c146117c18 100644 --- a/src/vs/workbench/test/node/api/extHostWorkspace.test.ts +++ b/src/vs/workbench/test/node/api/extHostWorkspace.test.ts @@ -20,4 +20,16 @@ suite('ExtHostWorkspace', function () { 'm:/Apps/DartPubCache/hosted/pub.dartlang.org/convert-2.0.1/lib/src/hex.dart'); }); + + test('asRelativePath, same paths, #11402', function () { + const root = '/home/aeschli/workspaces/samples/docker'; + const input = '/home/aeschli/workspaces/samples/docker'; + const ws = new ExtHostWorkspace(new TestThreadService(), root); + + assert.equal(ws.getRelativePath(input), input); + + const input2 = '/home/aeschli/workspaces/samples/docker/a.file'; + assert.equal(ws.getRelativePath(input2), 'a.file'); + + }); });