Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 11 additions & 4 deletions src/features/views/pythonStatusBar.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Disposable, StatusBarAlignment, StatusBarItem, ThemeColor } from 'vscode';
import { PythonEnvironment } from '../../api';
import { createStatusBarItem } from '../../common/window.apis';

export interface PythonStatusBar extends Disposable {
show(text?: string): void;
show(env?: PythonEnvironment): void;
hide(): void;
}

Expand All @@ -19,9 +20,15 @@ export class PythonStatusBarImpl implements Disposable {
this.disposables.push(this.statusBarItem);
}

public show(text?: string) {
this.statusBarItem.text = text ?? 'Select Python Interpreter';
this.statusBarItem.backgroundColor = text ? undefined : new ThemeColor('statusBarItem.warningBackground');
public show(env?: PythonEnvironment) {
if (env) {
this.statusBarItem.text = env.displayName ?? 'Select Python Interpreter';
this.statusBarItem.tooltip = env.environmentPath?.fsPath ?? '';
} else {
this.statusBarItem.text = 'Select Python Interpreter';
this.statusBarItem.tooltip = 'Select Python Interpreter';
}
this.statusBarItem.backgroundColor = env ? undefined : new ThemeColor('statusBarItem.warningBackground');
this.statusBarItem.show();
}

Expand Down
8 changes: 4 additions & 4 deletions src/features/views/revealHandler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { PythonEnvironmentApi } from '../../api';
import { isPythonProjectFile } from '../../common/utils/fileNameUtils';
import { activeTextEditor } from '../../common/window.apis';
import { ProjectView } from './projectView';
import { EnvManagerView } from './envManagersView';
import { ProjectView } from './projectView';
import { PythonStatusBar } from './pythonStatusBar';
import { isPythonProjectFile } from '../../common/utils/fileNameUtils';
import { PythonEnvironmentApi } from '../../api';

export function updateViewsAndStatus(
statusBar: PythonStatusBar,
Expand Down Expand Up @@ -31,7 +31,7 @@ export function updateViewsAndStatus(
workspaceView.reveal(activeDocument.uri);
setImmediate(async () => {
const env = await api.getEnvironment(activeDocument.uri);
statusBar.show(env?.displayName);
statusBar.show(env);
managerView.reveal(env);
});
}