Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/client/activation/jedi/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import '../../common/extensions';
import { inject, injectable, named } from 'inversify';

import { ICommandManager } from '../../common/application/types';
import { traceDecorators } from '../../common/logger';
import { traceDecorators, traceVerbose } from '../../common/logger';
import { IDisposable, Resource } from '../../common/types';
import { debounceSync } from '../../common/utils/decorators';
import { EXTENSION_ROOT_DIR } from '../../constants';
Expand Down Expand Up @@ -80,16 +80,22 @@ export class JediLanguageServerManager implements ILanguageServerManager {
this.interpreter = interpreter;
this.analysisOptions.onDidChange(this.restartLanguageServerDebounced, this, this.disposables);

// Version is actually hardcoded in our requirements.txt.
const requirementsTxt = await fs.readFile(path.join(EXTENSION_ROOT_DIR, 'requirements.txt'), 'utf-8');

// Search using a regex in the text
const match = /jedi-language-server==([0-9\.]*)/.exec(requirementsTxt);
if (match && match.length > 1) {
// eslint-disable-next-line prefer-destructuring
this.lsVersion = match[1];
} else {
this.lsVersion = '0.19.3';
try {
// Version is actually hardcoded in our requirements.txt.
const requirementsTxt = await fs.readFile(
path.join(EXTENSION_ROOT_DIR, 'jedils_requirements.txt'),
'utf-8',
);

// Search using a regex in the text
const match = /jedi-language-server==([0-9\.]*)/.exec(requirementsTxt);
if (match && match.length === 2) {
[, this.lsVersion] = match;
}
} catch (ex) {
// Getting version here is best effort and does not affect how LS works and
// failing to get version should not stop LS from working.
traceVerbose('Failed to get jedi-language-server version: ', ex);
}

await this.analysisOptions.initialize(resource, interpreter);
Expand Down