Skip to content

Commit c1a3474

Browse files
committed
Wire up to combobox
1 parent be0594a commit c1a3474

File tree

6 files changed

+38
-9
lines changed

6 files changed

+38
-9
lines changed

src/client/datascience/jupyter/jupyterExecution.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { CancellationToken, Event, EventEmitter, Uri } from 'vscode';
1212

1313
import { ILiveShareApi, IWorkspaceService } from '../../common/application/types';
1414
import { Cancellation, CancellationError } from '../../common/cancellation';
15+
import { PYTHON_LANGUAGE } from '../../common/constants';
1516
import { traceInfo } from '../../common/logger';
1617
import { IFileSystem, TemporaryDirectory } from '../../common/platform/types';
1718
import { IProcessServiceFactory, IPythonExecutionFactory, SpawnOptions } from '../../common/process/types';
@@ -232,7 +233,7 @@ export class JupyterExecutionBase implements IJupyterExecution {
232233
private async enumerateInterpreterVersions() : Promise<IRunnableJupyter[]> {
233234
// Find all interpreters that support jupyter notebook. That's the minimum required to start.
234235
const interpreters = await this.interpreterService.getInterpreters();
235-
const possible = await Promise.all(interpreters.map(this.getInterpreterVersion));
236+
const possible = await Promise.all(interpreters.map(this.getInterpreterVersion.bind(this)));
236237
return possible.filter(p => p !== undefined) as IRunnableJupyter[];
237238
}
238239

@@ -567,7 +568,7 @@ export class JupyterExecutionBase implements IJupyterExecution {
567568

568569
// For each get its details as we will likely need them
569570
const specDetails = await Promise.all(specs.map(async s => {
570-
if (s && s.path && s.path.length > 0 && await fs.pathExists(s.path)) {
571+
if (s && s.language === PYTHON_LANGUAGE && s.path && s.path.length > 0 && await fs.pathExists(s.path)) {
571572
return this.interpreterService.getInterpreterDetails(s.path);
572573
}
573574
}));

src/client/datascience/jupyter/runnableJupyterCache.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class RunnableJupyterCache implements IRunnableJupyterCache {
4040
const current = await this.interpreterService.getActiveInterpreter(resource);
4141

4242
// Find the closest match
43-
if (current && current.version) {
43+
if (current) {
4444
let bestScore = -1;
4545
for (const entry of versions) {
4646
let currentScore = 0;
@@ -50,7 +50,7 @@ export class RunnableJupyterCache implements IRunnableJupyterCache {
5050
// Interpreter based (local)
5151
const interpreter = entry.interpreter;
5252
const version = interpreter ? interpreter.version : undefined;
53-
if (version) {
53+
if (version && current.version) {
5454
if (version.major === current.version.major) {
5555
currentScore += 4;
5656
if (version.minor === current.version.minor) {
@@ -61,6 +61,11 @@ export class RunnableJupyterCache implements IRunnableJupyterCache {
6161
}
6262
}
6363
}
64+
const name = entry.name;
65+
if (current.displayName === name) {
66+
// This is likely an exact match
67+
currentScore += 8;
68+
}
6469
// Kernel based (remote)
6570
const kernelSpec = entry.spec;
6671
if (kernelSpec) {

src/datascience-ui/history-react/mainPanelState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ export function generateTestState(inputBlockToggled : (id: string) => void, file
6262
tokenizerLoaded: true,
6363
editorOptions: {},
6464
currentExecutionCount: 0,
65-
runnableVersions: [],
66-
currentRunnableVersion: -1
65+
runnableVersions: [{ name: 'My Jupyter', type: 'local' }],
66+
currentRunnableVersion: 0
6767
};
6868
}
6969

src/datascience-ui/history-react/toolbarPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export class ToolbarPanel extends React.Component<IToolbarPanelProps> {
4545
const { runnableVersions, currentVersion } = this.generateRunnableVersions();
4646
return(
4747
<div id='toolbar-panel'>
48-
<ComboBox values={runnableVersions} currentValue={currentVersion} onChange={this.changeRunnable} />
4948
<MenuBar baseTheme={this.props.baseTheme}>
49+
<ComboBox values={runnableVersions} currentValue={currentVersion} onChange={this.changeRunnable} />
5050
<ImageButton baseTheme={this.props.baseTheme} onClick={this.props.clearAll} tooltip={getLocString('DataScience.clearAll', 'Remove All Cells')}>
5151
<Image baseTheme={this.props.baseTheme} class='image-button-image' image={ImageName.Cancel}/>
5252
</ImageButton>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.combobox-container {
2+
background-color: var(--vscode-editor-background);
3+
}
4+
5+
.combobox__control {
6+
background-color: var(--vscode-editor-background);
7+
}
8+
9+
.combobox__value-indicator {
10+
background-color: var(--vscode-editor-background);
11+
}
12+
13+
.combobox__indicators {
14+
background-color: var(--vscode-editor-background);
15+
}

src/datascience-ui/react-common/comboBox.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
'use strict';
55

66
import * as React from 'react';
7-
import Select from 'react-select/lib/Select';
7+
// tslint:disable-next-line: import-name match-default-export-name
8+
import Select from 'react-select';
89
import { ValueType } from 'react-select/lib/types';
910

11+
import './comboBox.css';
12+
1013
interface IComboBoxProps {
1114
values: { value: string; label: string }[];
1215
currentValue: number;
@@ -21,7 +24,12 @@ export class ComboBox extends React.Component<IComboBoxProps> {
2124
public render() {
2225
const currentValue = this.props.values.length > this.props.currentValue ? this.props.values[this.props.currentValue] : undefined ;
2326
return (
24-
<Select value={currentValue} options={this.props.values} onChange={this.props.onChange}/>
27+
<Select
28+
classNamePrefix='combobox'
29+
className='combobox-container'
30+
value={currentValue}
31+
options={this.props.values}
32+
onChange={this.props.onChange}/>
2533
);
2634
}
2735

0 commit comments

Comments
 (0)