From e27cc212990c8647f893020c3b79ebf969a9ae9b Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Mon, 14 Oct 2019 13:02:00 +0200 Subject: [PATCH] fix #65561 --- .../api/common/extHostTypeConverters.ts | 2 +- .../api/extHostTypeConverter.test.ts | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/api/common/extHostTypeConverters.ts b/src/vs/workbench/api/common/extHostTypeConverters.ts index 608b6d90707..24dd0936044 100644 --- a/src/vs/workbench/api/common/extHostTypeConverters.ts +++ b/src/vs/workbench/api/common/extHostTypeConverters.ts @@ -283,7 +283,7 @@ export namespace MarkdownString { } let data: any; try { - data = parse(decodeURIComponent(part)); + data = parse(part); } catch (e) { // ignore } diff --git a/src/vs/workbench/test/electron-browser/api/extHostTypeConverter.test.ts b/src/vs/workbench/test/electron-browser/api/extHostTypeConverter.test.ts index 89a32a67959..aac33827faa 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostTypeConverter.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostTypeConverter.test.ts @@ -7,9 +7,10 @@ import * as assert from 'assert'; import { MarkdownString, LogLevel } from 'vs/workbench/api/common/extHostTypeConverters'; import { isEmptyObject } from 'vs/base/common/types'; -import { size } from 'vs/base/common/collections'; +import { size, forEach } from 'vs/base/common/collections'; import * as types from 'vs/workbench/api/common/extHostTypes'; import { LogLevel as _MainLogLevel } from 'vs/platform/log/common/log'; +import { URI } from 'vs/base/common/uri'; suite('ExtHostTypeConverter', function () { @@ -59,6 +60,20 @@ suite('ExtHostTypeConverter', function () { assert.ok(!!data.uris!['file:///somepath/here2']); }); + test('NPM script explorer running a script from the hover does not work #65561', function () { + + let data = MarkdownString.from('*hello* [click](command:npm.runScriptFromHover?%7B%22documentUri%22%3A%7B%22%24mid%22%3A1%2C%22external%22%3A%22file%3A%2F%2F%2Fc%253A%2Ffoo%2Fbaz.ex%22%2C%22path%22%3A%22%2Fc%3A%2Ffoo%2Fbaz.ex%22%2C%22scheme%22%3A%22file%22%7D%2C%22script%22%3A%22dev%22%7D)'); + // assert that both uri get extracted but that the latter is only decoded once... + assert.equal(size(data.uris!), 2); + forEach(data.uris!, entry => { + if (entry.value.scheme === 'file') { + assert.ok(URI.revive(entry.value).toString().indexOf('file:///c%3A') === 0); + } else { + assert.equal(entry.value.scheme, 'command'); + } + }); + }); + test('LogLevel', () => { assert.equal(LogLevel.from(types.LogLevel.Error), _MainLogLevel.Error); assert.equal(LogLevel.from(types.LogLevel.Info), _MainLogLevel.Info); -- GitLab