Skip to content

Commit 74ec72f

Browse files
committed
ish
1 parent d20d357 commit 74ec72f

File tree

4 files changed

+26
-44
lines changed

4 files changed

+26
-44
lines changed

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@
219219
"category": "Python",
220220
"icon": "$(search)"
221221
},
222+
{
223+
"command": "python-envs.searchSettings",
224+
"title": "%python-envs.searchSettings.title%",
225+
"category": "Python",
226+
"icon": "$(gear)"
227+
},
222228
{
223229
"command": "python-envs.refreshPackages",
224230
"title": "%python-envs.refreshPackages.title%",
@@ -556,6 +562,11 @@
556562
"group": "navigation",
557563
"when": "view == env-managers"
558564
},
565+
{
566+
"command": "python-envs.searchSettings",
567+
"group": "navigation",
568+
"when": "view == env-managers"
569+
},
559570
{
560571
"command": "python-envs.refreshAllManagers",
561572
"group": "navigation",

package.nls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"python-envs.setEnvSelected.title": "Set!",
3232
"python-envs.remove.title": "Delete Environment",
3333
"python-envs.refreshAllManagers.title": "Refresh All Environment Managers",
34-
"python-envs.managerSearch.title": "Manage Environment Search",
34+
"python-envs.managerSearch.title": "Search Workspace for Environments",
35+
"python-envs.searchSettings.title": "Configure Search Settings",
3536
"python-envs.refreshPackages.title": "Refresh Packages List",
3637
"python-envs.packages.title": "Manage Packages",
3738
"python-envs.clearCache.title": "Clear Cache",

src/extension.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { commands, ExtensionContext, LogOutputChannel, Terminal, Uri, window } from 'vscode';
2-
import { version as extensionVersion } from '../package.json';
32
import { PythonEnvironment, PythonEnvironmentApi, PythonProjectCreator } from './api';
43
import { ensureCorrectVersion } from './common/extVersion';
5-
import { registerLogger, traceError, traceInfo, traceVerbose, traceWarn } from './common/logging';
4+
import { registerLogger, traceError, traceInfo, traceWarn } from './common/logging';
65
import { clearPersistentState, setPersistentState } from './common/persistentState';
76
import { newProjectSelection } from './common/pickers/managers';
87
import { StopWatch } from './common/stopWatch';
@@ -66,7 +65,7 @@ import { TerminalEnvVarInjector } from './features/terminal/terminalEnvVarInject
6665
import { TerminalManager, TerminalManagerImpl } from './features/terminal/terminalManager';
6766
import { registerTerminalPackageWatcher } from './features/terminal/terminalPackageWatcher';
6867
import { getEnvironmentForTerminal } from './features/terminal/utils';
69-
import { handleEnvManagerSearchAction } from './features/views/envManagerSearch';
68+
import { handleEnvManagerSearchAction, openSearchSettings } from './features/views/envManagerSearch';
7069
import { EnvManagerView } from './features/views/envManagersView';
7170
import { ProjectView } from './features/views/projectView';
7271
import { PythonStatusBarImpl } from './features/views/pythonStatusBar';
@@ -103,7 +102,6 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
103102
ensureCorrectVersion();
104103

105104
// log extension version
106-
traceVerbose(`Python-envs extension version: ${extensionVersion}`);
107105
// log settings
108106
const configLevels = getEnvManagerAndPackageManagerConfigLevels();
109107
traceInfo(`\n=== ${configLevels.section} ===`);
@@ -185,6 +183,9 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
185183
const nativeFinder = await nativeFinderDeferred.promise;
186184
await handleEnvManagerSearchAction(envManagers, nativeFinder);
187185
}),
186+
commands.registerCommand('python-envs.searchSettings', async () => {
187+
await openSearchSettings();
188+
}),
188189
commands.registerCommand('python-envs.refreshPackages', async (item) => {
189190
await refreshPackagesCommand(item, envManagers);
190191
}),

src/features/views/envManagerSearch.ts

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as path from 'path';
2-
import { commands, ConfigurationTarget, QuickPickItem, window } from 'vscode';
2+
import { commands, ConfigurationTarget, window } from 'vscode';
33
import { Common, EnvManagerSearchStrings } from '../../common/localize';
44
import { traceLog } from '../../common/logging';
55
import { getWorkspacePersistentState } from '../../common/persistentState';
@@ -8,54 +8,23 @@ import { getConfiguration, getWorkspaceFolders } from '../../common/workspace.ap
88
import { EnvironmentManagers } from '../../internal.api';
99
import { NativePythonFinder } from '../../managers/common/nativePythonFinder';
1010

11-
type SearchAction = 'settings' | 'fullSearch';
12-
13-
interface SearchActionItem extends QuickPickItem {
14-
action: SearchAction;
15-
}
16-
1711
const SUPPRESS_SAVE_PROMPT_KEY = 'python-envs.search.fullWorkspace.suppressSavePrompt';
1812

1913
/**
20-
* Handles the "Manage Environment Search" action from the Environment Managers view.
21-
* Presents a quick pick menu allowing users to either adjust search path settings
22-
* or perform a full workspace search for Python environments.
14+
* Handles the Environment Managers view search action.
15+
* Performs a full workspace search for Python environments.
2316
*/
2417
export async function handleEnvManagerSearchAction(
2518
envManagers: EnvironmentManagers,
2619
nativeFinder: NativePythonFinder,
2720
): Promise<void> {
28-
const items: SearchActionItem[] = [
29-
{
30-
label: EnvManagerSearchStrings.adjustSearchPaths,
31-
description: EnvManagerSearchStrings.adjustSearchPathsDescription,
32-
action: 'settings',
33-
},
34-
{
35-
label: EnvManagerSearchStrings.fullWorkspaceSearch,
36-
description: EnvManagerSearchStrings.fullWorkspaceSearchDescription,
37-
action: 'fullSearch',
38-
},
39-
];
40-
41-
const selection = await window.showQuickPick(items, {
42-
placeHolder: EnvManagerSearchStrings.selectAction,
43-
matchOnDescription: true,
44-
});
45-
46-
if (!selection) {
47-
return;
48-
}
49-
50-
if (selection.action === 'settings') {
51-
await openSearchSettings();
52-
return;
53-
}
54-
5521
await runFullWorkspaceSearch(envManagers, nativeFinder);
5622
}
5723

58-
async function openSearchSettings(): Promise<void> {
24+
/**
25+
* Opens environment search settings.
26+
*/
27+
export async function openSearchSettings(): Promise<void> {
5928
await commands.executeCommand('workbench.action.openSettings', '@ext:ms-python.vscode-python-envs "search path"');
6029
}
6130

@@ -64,7 +33,7 @@ async function openSearchSettings(): Promise<void> {
6433
* Uses the `./**` glob pattern to search the entire workspace tree.
6534
* After the search completes, prompts the user to save the search pattern to settings.
6635
*/
67-
async function runFullWorkspaceSearch(
36+
export async function runFullWorkspaceSearch(
6837
envManagers: EnvironmentManagers,
6938
nativeFinder: NativePythonFinder,
7039
): Promise<void> {

0 commit comments

Comments
 (0)