mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:28:52 +01:00
Use less than for TS version checks instead of inverting greater than checks
This commit is contained in:
@@ -350,7 +350,7 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
|
||||
private getTsTriggerCharacter(context: vscode.CompletionContext): Proto.CompletionsTriggerCharacter | undefined {
|
||||
// Workaround for https://github.com/Microsoft/TypeScript/issues/27321
|
||||
if (context.triggerCharacter === '@'
|
||||
&& this.client.apiVersion.gte(API.v310) && !this.client.apiVersion.gte(API.v320)
|
||||
&& this.client.apiVersion.gte(API.v310) && this.client.apiVersion.lt(API.v320)
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -480,7 +480,7 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
|
||||
line: vscode.TextLine,
|
||||
position: vscode.Position
|
||||
): boolean {
|
||||
if (context.triggerCharacter && !this.client.apiVersion.gte(API.v290)) {
|
||||
if (context.triggerCharacter && this.client.apiVersion.lt(API.v290)) {
|
||||
if ((context.triggerCharacter === '"' || context.triggerCharacter === '\'')) {
|
||||
// make sure we are in something that looks like the start of an import
|
||||
const pre = line.text.slice(0, position.character);
|
||||
|
||||
@@ -176,7 +176,7 @@ export default class FileConfigurationManager {
|
||||
}
|
||||
|
||||
private getPreferences(document: vscode.TextDocument): Proto.UserPreferences {
|
||||
if (!this.client.apiVersion.gte(API.v290)) {
|
||||
if (this.client.apiVersion.lt(API.v290)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -282,7 +282,7 @@ class TypeScriptQuickFixProvider implements vscode.CodeActionProvider {
|
||||
diagnostic: vscode.Diagnostic,
|
||||
tsAction: Proto.CodeFixAction,
|
||||
): CodeActionSet {
|
||||
if (!tsAction.fixId || !this.client.apiVersion.gte(API.v270) || results.hasFixAllAction(results)) {
|
||||
if (!tsAction.fixId || this.client.apiVersion.lt(API.v270) || results.hasFixAllAction(results)) {
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class UpdateImportsOnFileRenameHandler {
|
||||
this.client.bufferSyncSupport.closeResource(targetResource);
|
||||
this.client.bufferSyncSupport.openTextDocument(document);
|
||||
|
||||
if (!this.client.apiVersion.gte(API.v300) && !fs.lstatSync(newResource.fsPath).isDirectory()) {
|
||||
if (this.client.apiVersion.lt(API.v300) && !fs.lstatSync(newResource.fsPath).isDirectory()) {
|
||||
// Workaround for https://github.com/Microsoft/vscode/issues/52967
|
||||
// Never attempt to update import paths if the file does not contain something the looks like an export
|
||||
try {
|
||||
@@ -253,7 +253,7 @@ class UpdateImportsOnFileRenameHandler {
|
||||
const edits: Proto.FileCodeEdits[] = [];
|
||||
for (const edit of response.body) {
|
||||
// Workaround for https://github.com/Microsoft/vscode/issues/52675
|
||||
if (!this.client.apiVersion.gte(API.v300)) {
|
||||
if (this.client.apiVersion.lt(API.v300)) {
|
||||
if ((edit as Proto.FileCodeEdits).fileName.match(/[\/\\]node_modules[\/\\]/gi)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||
|
||||
this.client.ensureServiceStarted();
|
||||
this.client.onReady(() => {
|
||||
if (!this.client.apiVersion.gte(API.v230)) {
|
||||
if (this.client.apiVersion.lt(API.v230)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
}
|
||||
|
||||
public async openTsServerLogFile(): Promise<boolean> {
|
||||
if (!this.apiVersion.gte(API.v222)) {
|
||||
if (this.apiVersion.lt(API.v222)) {
|
||||
vscode.window.showErrorMessage(
|
||||
localize(
|
||||
'typescript.openTsServerLog.notSupported',
|
||||
@@ -409,7 +409,7 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||
}
|
||||
|
||||
private setCompilerOptionsForInferredProjects(configuration: TypeScriptServiceConfiguration): void {
|
||||
if (!this.apiVersion.gte(API.v206)) {
|
||||
if (this.apiVersion.lt(API.v206)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,4 +56,8 @@ export default class API {
|
||||
public gte(other: API): boolean {
|
||||
return semver.gte(this.version, other.version);
|
||||
}
|
||||
|
||||
public lt(other: API): boolean {
|
||||
return !this.gte(other);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user