mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
CSS autocomplete in html files not working on Windows.Fixes #14467
This commit is contained in:
27
extensions/html/server/src/test/embeddedContentUri.test.ts
Normal file
27
extensions/html/server/src/test/embeddedContentUri.test.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import {getEmbeddedContentUri, getEmbeddedLanguageId, getHostDocumentUri, isEmbeddedContentUri} from './embeddedContentUri';
|
||||
|
||||
suite('Embedded URI', () => {
|
||||
|
||||
test('URI', function (): any {
|
||||
let resourceUri1 = 'file:///c%3A/workspaces/samples/foo.html';
|
||||
let resourceUri2 = 'file://Users/joe/samples/foo.html';
|
||||
|
||||
let uri = getEmbeddedContentUri(resourceUri1, 'css');
|
||||
assert(isEmbeddedContentUri(uri));
|
||||
assert.equal(getEmbeddedLanguageId(uri), 'css');
|
||||
assert.equal(getHostDocumentUri(uri), resourceUri1);
|
||||
|
||||
let uri2 = getEmbeddedContentUri(resourceUri2, 'css');
|
||||
assert(isEmbeddedContentUri(uri2));
|
||||
assert.equal(getEmbeddedLanguageId(uri2), 'css');
|
||||
assert.equal(getHostDocumentUri(uri2), resourceUri2);
|
||||
});
|
||||
|
||||
});
|
||||
27
extensions/html/server/src/test/embeddedContentUri.ts
Normal file
27
extensions/html/server/src/test/embeddedContentUri.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import Uri from 'vscode-uri';
|
||||
|
||||
export const EMBEDDED_CONTENT_SCHEME = 'embedded-content';
|
||||
|
||||
export function isEmbeddedContentUri(virtualDocumentUri: Uri): boolean {
|
||||
return virtualDocumentUri.scheme === EMBEDDED_CONTENT_SCHEME;
|
||||
}
|
||||
|
||||
export function getEmbeddedContentUri(parentDocumentUri: string, embeddedLanguageId: string): Uri {
|
||||
return Uri.from({ scheme: EMBEDDED_CONTENT_SCHEME, authority: embeddedLanguageId, path: '/' + encodeURIComponent(parentDocumentUri) + '.' + embeddedLanguageId });
|
||||
};
|
||||
|
||||
export function getHostDocumentUri(virtualDocumentUri: Uri): string {
|
||||
let languageId = virtualDocumentUri.authority;
|
||||
let path = virtualDocumentUri.path.substring(1, virtualDocumentUri.path.length - languageId.length - 1); // remove leading '/' and new file extension
|
||||
return decodeURIComponent(path);
|
||||
};
|
||||
|
||||
export function getEmbeddedLanguageId(virtualDocumentUri: Uri): string {
|
||||
return virtualDocumentUri.authority;
|
||||
}
|
||||
Reference in New Issue
Block a user