Skip to content

Commit d472e4b

Browse files
committed
remove unneeded edits
1 parent b4563cd commit d472e4b

File tree

2 files changed

+1
-53
lines changed

2 files changed

+1
-53
lines changed

src/client/pythonEnvironments/base/locators/common/nativePythonFinder.ts

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,6 @@ class NativePythonFinderImpl extends DisposableBase implements NativePythonFinde
114114

115115
private readonly suppressErrorNotification: IPersistentStorage<boolean>;
116116

117-
/**
118-
* Tracks whether the internal JSON-RPC connection has been closed.
119-
* This can happen independently of the finder being disposed.
120-
*/
121-
private _connectionClosed = false;
122-
123-
public get isConnectionClosed(): boolean {
124-
return this._connectionClosed;
125-
}
126-
127117
constructor(private readonly cacheDirectory?: Uri, private readonly context?: IExtensionContext) {
128118
super();
129119
this.suppressErrorNotification = this.context
@@ -145,21 +135,14 @@ class NativePythonFinderImpl extends DisposableBase implements NativePythonFinde
145135
}
146136

147137
async *refresh(options?: NativePythonEnvironmentKind | Uri[]): AsyncIterable<NativeEnvInfo> {
148-
this.outputChannel.info(
149-
`refresh() called: firstRefreshResults=${!!this.firstRefreshResults}, connectionClosed=${
150-
this._connectionClosed
151-
}, isDisposed=${this.isDisposed}`,
152-
);
153138
if (this.firstRefreshResults) {
154139
// If this is the first time we are refreshing,
155140
// Then get the results from the first refresh.
156141
// Those would have started earlier and cached in memory.
157-
this.outputChannel.info('Using firstRefreshResults');
158142
const results = this.firstRefreshResults();
159143
this.firstRefreshResults = undefined;
160144
yield* results;
161145
} else {
162-
this.outputChannel.info('Calling doRefresh');
163146
const result = this.doRefresh(options);
164147
let completed = false;
165148
void result.completed.finally(() => {
@@ -315,8 +298,6 @@ class NativePythonFinderImpl extends DisposableBase implements NativePythonFinde
315298
sendNativeTelemetry(data, this.initialRefreshMetrics),
316299
),
317300
connection.onClose(() => {
318-
this.outputChannel.info('JSON-RPC connection closed, marking connection as closed');
319-
this._connectionClosed = true;
320301
disposables.forEach((d) => d.dispose());
321302
}),
322303
);
@@ -540,9 +521,6 @@ export function getNativePythonFinder(context?: IExtensionContext): NativePython
540521
},
541522
};
542523
}
543-
if (_finder && isFinderDisposed(_finder)) {
544-
_finder = undefined;
545-
}
546524
if (!_finder) {
547525
const cacheDirectory = context ? getCacheDirectory(context) : undefined;
548526
_finder = new NativePythonFinderImpl(cacheDirectory, context);
@@ -553,18 +531,6 @@ export function getNativePythonFinder(context?: IExtensionContext): NativePython
553531
return _finder;
554532
}
555533

556-
function isFinderDisposed(finder: NativePythonFinder): boolean {
557-
const finderImpl = finder as { isDisposed?: boolean; isConnectionClosed?: boolean };
558-
const disposed = Boolean(finderImpl.isDisposed);
559-
const connectionClosed = Boolean(finderImpl.isConnectionClosed);
560-
if (disposed || connectionClosed) {
561-
traceError(
562-
`[NativePythonFinder] Finder needs recreation: isDisposed=${disposed}, isConnectionClosed=${connectionClosed}`,
563-
);
564-
}
565-
return disposed || connectionClosed;
566-
}
567-
568534
export function getCacheDirectory(context: IExtensionContext): Uri {
569535
return Uri.joinPath(context.globalStorageUri, 'pythonLocator');
570536
}
@@ -573,14 +539,3 @@ export async function clearCacheDirectory(context: IExtensionContext): Promise<v
573539
const cacheDirectory = getCacheDirectory(context);
574540
await fs.emptyDir(cacheDirectory.fsPath).catch(noop);
575541
}
576-
577-
/**
578-
* Clears the singleton finder instance. For testing purposes only.
579-
* @internal
580-
*/
581-
export function clearNativePythonFinder(): void {
582-
if (_finder) {
583-
_finder.dispose();
584-
_finder = undefined;
585-
}
586-
}

src/test/pythonEnvironments/nativePythonFinder.unit.test.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import * as sinon from 'sinon';
66
import * as typemoq from 'typemoq';
77
import { WorkspaceConfiguration } from 'vscode';
88
import {
9-
clearNativePythonFinder,
109
getNativePythonFinder,
1110
isNativeEnvInfo,
1211
NativeEnvInfo,
@@ -24,9 +23,6 @@ suite('Native Python Finder', () => {
2423
let getWorkspaceFolderPathsStub: sinon.SinonStub;
2524

2625
setup(() => {
27-
// Clear singleton before each test to ensure fresh state
28-
clearNativePythonFinder();
29-
3026
createLogOutputChannelStub = sinon.stub(windowsApis, 'createLogOutputChannel');
3127
createLogOutputChannelStub.returns(new MockOutputChannel('locator'));
3228

@@ -45,14 +41,11 @@ suite('Native Python Finder', () => {
4541
});
4642

4743
teardown(() => {
48-
// Clean up finder before restoring stubs to avoid issues with mock references
49-
clearNativePythonFinder();
5044
sinon.restore();
5145
});
5246

5347
suiteTeardown(() => {
54-
// Final cleanup (finder may already be disposed by teardown)
55-
clearNativePythonFinder();
48+
finder.dispose();
5649
});
5750

5851
test('Refresh should return python environments', async () => {

0 commit comments

Comments
 (0)