Skip to content

Commit

Permalink
Make sure we do not enable JS/TS language features on live share clients
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Aug 18, 2020
1 parent c709fd3 commit f694b07
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TsServerProcessFactory } from './tsServer/server';
import { ITypeScriptVersionProvider } from './tsServer/versionProvider';
import TypeScriptServiceClientHost from './typeScriptServiceClientHost';
import { flatten } from './utils/arrays';
import * as fileSchemes from './utils/fileSchemes';
import { standardLanguageDescriptions } from './utils/languageDescription';
import { lazy, Lazy } from './utils/lazy';
import ManagedFileContextManager from './utils/managedFileContext';
Expand Down Expand Up @@ -85,5 +86,6 @@ function isSupportedDocument(
supportedLanguage: readonly string[],
document: vscode.TextDocument
): boolean {
return supportedLanguage.indexOf(document.languageId) >= 0;
return supportedLanguage.indexOf(document.languageId) >= 0
&& !fileSchemes.disabledSchemes.has(document.uri.scheme);
}
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,10 @@ export default class TypeScriptServiceClient extends Disposable implements IType
}

public normalizedPath(resource: vscode.Uri): string | undefined {
if (fileSchemes.disabledSchemes.has(resource.scheme)) {
return undefined;
}

switch (resource.scheme) {
case fileSchemes.file:
{
Expand All @@ -648,10 +652,6 @@ export default class TypeScriptServiceClient extends Disposable implements IType
// Both \ and / must be escaped in regular expressions
return result.replace(new RegExp('\\' + this.pathSeparator, 'g'), '/');
}
case fileSchemes.git:
{
return undefined;
}
default:
{
return this.inMemoryResourcePrefix + resource.toString(true);
Expand All @@ -665,7 +665,9 @@ export default class TypeScriptServiceClient extends Disposable implements IType

public toOpenedFilePath(document: vscode.TextDocument): string | undefined {
if (!this.bufferSyncSupport.ensureHasBuffer(document.uri)) {
console.error(`Unexpected resource ${document.uri}`);
if (!fileSchemes.disabledSchemes.has(document.uri.scheme)) {
console.error(`Unexpected resource ${document.uri}`);
}
return undefined;
}
return this.toPath(document.uri) || undefined;
Expand Down
10 changes: 10 additions & 0 deletions extensions/typescript-language-features/src/utils/fileSchemes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@
export const file = 'file';
export const untitled = 'untitled';
export const git = 'git';
/** Live share scheme */
export const vsls = 'vsls';
export const walkThroughSnippet = 'walkThroughSnippet';

export const semanticSupportedSchemes = [
file,
untitled,
];

/**
* File scheme for which JS/TS language feature should be disabled
*/
export const disabledSchemes = new Set([
git,
vsls
]);

0 comments on commit f694b07

Please sign in to comment.