mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
CSS autocomplete in html files not working on Windows.Fixes #14467
This commit is contained in:
parent
fa60f3cb02
commit
3d6c220d24
|
@ -13,7 +13,7 @@ export function isEmbeddedContentUri(virtualDocumentUri: Uri): boolean {
|
|||
}
|
||||
|
||||
export function getEmbeddedContentUri(parentDocumentUri: string, embeddedLanguageId: string): Uri {
|
||||
return Uri.parse(EMBEDDED_CONTENT_SCHEME + '://' + embeddedLanguageId + '/' + encodeURIComponent(parentDocumentUri) + '.' + embeddedLanguageId);
|
||||
return new Uri().with({ scheme: EMBEDDED_CONTENT_SCHEME, authority: embeddedLanguageId, path: '/' + encodeURIComponent(parentDocumentUri) + '.' + embeddedLanguageId });
|
||||
};
|
||||
|
||||
export function getHostDocumentUri(virtualDocumentUri: Uri): string {
|
||||
|
|
|
@ -13,7 +13,7 @@ export function isEmbeddedContentUri(virtualDocumentUri: Uri): boolean {
|
|||
}
|
||||
|
||||
export function getEmbeddedContentUri(parentDocumentUri: string, embeddedLanguageId: string): Uri {
|
||||
return Uri.parse(EMBEDDED_CONTENT_SCHEME + '://' + embeddedLanguageId + '/' + encodeURIComponent(parentDocumentUri) + '.' + embeddedLanguageId);
|
||||
return Uri.from({ scheme: EMBEDDED_CONTENT_SCHEME, authority: embeddedLanguageId, path: '/' + encodeURIComponent(parentDocumentUri) + '.' + embeddedLanguageId });
|
||||
};
|
||||
|
||||
export function getHostDocumentUri(virtualDocumentUri: Uri): string {
|
||||
|
|
|
@ -13,7 +13,7 @@ export function isEmbeddedContentUri(virtualDocumentUri: Uri): boolean {
|
|||
}
|
||||
|
||||
export function getEmbeddedContentUri(parentDocumentUri: string, embeddedLanguageId: string): Uri {
|
||||
return Uri.parse(EMBEDDED_CONTENT_SCHEME + '://' + embeddedLanguageId + '/' + encodeURIComponent(parentDocumentUri) + '.' + embeddedLanguageId);
|
||||
return new Uri().with({ scheme: EMBEDDED_CONTENT_SCHEME, authority: embeddedLanguageId, path: '/' + encodeURIComponent(parentDocumentUri) + '.' + embeddedLanguageId });
|
||||
};
|
||||
|
||||
export function getHostDocumentUri(virtualDocumentUri: Uri): string {
|
||||
|
|
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;
|
||||
}
|
Loading…
Reference in a new issue