From 8bcf04648295cdecc845b1c3adb494a6c9319408 Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Mon, 30 Sep 2024 22:47:07 -0700 Subject: [PATCH] Remove unnecessary file read on execution (#24196) Unused event that is not needed for file execution. --- .../codeExecution/codeExecutionManager.ts | 17 +---------------- src/client/terminals/types.ts | 1 - .../codeExecutionManager.unit.test.ts | 5 ----- 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/client/terminals/codeExecution/codeExecutionManager.ts b/src/client/terminals/codeExecution/codeExecutionManager.ts index 061918b7a74a..ff665af1a07a 100644 --- a/src/client/terminals/codeExecution/codeExecutionManager.ts +++ b/src/client/terminals/codeExecution/codeExecutionManager.ts @@ -4,12 +4,11 @@ 'use strict'; import { inject, injectable } from 'inversify'; -import { Disposable, Event, EventEmitter, Uri } from 'vscode'; +import { Disposable, EventEmitter, Uri } from 'vscode'; import { ICommandManager, IDocumentManager } from '../../common/application/types'; import { Commands } from '../../common/constants'; import '../../common/extensions'; -import { IFileSystem } from '../../common/platform/types'; import { IDisposableRegistry, IConfigurationService, Resource } from '../../common/types'; import { noop } from '../../common/utils/misc'; import { IInterpreterService } from '../../interpreter/contracts'; @@ -30,15 +29,10 @@ export class CodeExecutionManager implements ICodeExecutionManager { @inject(ICommandManager) private commandManager: ICommandManager, @inject(IDocumentManager) private documentManager: IDocumentManager, @inject(IDisposableRegistry) private disposableRegistry: Disposable[], - @inject(IFileSystem) private fileSystem: IFileSystem, @inject(IConfigurationService) private readonly configSettings: IConfigurationService, @inject(IServiceContainer) private serviceContainer: IServiceContainer, ) {} - public get onExecutedCode(): Event { - return this.eventEmitter.event; - } - public registerCommands() { [Commands.Exec_In_Terminal, Commands.Exec_In_Terminal_Icon, Commands.Exec_In_Separate_Terminal].forEach( (cmd) => { @@ -127,15 +121,6 @@ export class CodeExecutionManager implements ICodeExecutionManager { fileToExecute = fileAfterSave; } - try { - const contents = await this.fileSystem.readFile(fileToExecute.fsPath); - this.eventEmitter.fire(contents); - } catch { - // Ignore any errors that occur for firing this event. It's only used - // for telemetry - noop(); - } - const executionService = this.serviceContainer.get(ICodeExecutionService, 'standard'); await executionService.executeFile(fileToExecute, options); } diff --git a/src/client/terminals/types.ts b/src/client/terminals/types.ts index ada3acd851a9..5fd129e8fe89 100644 --- a/src/client/terminals/types.ts +++ b/src/client/terminals/types.ts @@ -24,7 +24,6 @@ export interface ICodeExecutionHelper { export const ICodeExecutionManager = Symbol('ICodeExecutionManager'); export interface ICodeExecutionManager { - onExecutedCode: Event; registerCommands(): void; } diff --git a/src/test/terminals/codeExecution/codeExecutionManager.unit.test.ts b/src/test/terminals/codeExecution/codeExecutionManager.unit.test.ts index 29c310f6c724..be58ecbc8e6b 100644 --- a/src/test/terminals/codeExecution/codeExecutionManager.unit.test.ts +++ b/src/test/terminals/codeExecution/codeExecutionManager.unit.test.ts @@ -7,7 +7,6 @@ import { Disposable, TextDocument, TextEditor, Uri } from 'vscode'; import { ICommandManager, IDocumentManager, IWorkspaceService } from '../../../client/common/application/types'; import { Commands } from '../../../client/common/constants'; -import { IFileSystem } from '../../../client/common/platform/types'; import { IServiceContainer } from '../../../client/ioc/types'; import { CodeExecutionManager } from '../../../client/terminals/codeExecution/codeExecutionManager'; import { ICodeExecutionHelper, ICodeExecutionManager, ICodeExecutionService } from '../../../client/terminals/types'; @@ -24,12 +23,9 @@ suite('Terminal - Code Execution Manager', () => { let serviceContainer: TypeMoq.IMock; let documentManager: TypeMoq.IMock; let configService: TypeMoq.IMock; - let fileSystem: TypeMoq.IMock; let interpreterService: TypeMoq.IMock; let triggerCreateEnvironmentCheckNonBlockingStub: sinon.SinonStub; setup(() => { - fileSystem = TypeMoq.Mock.ofType(); - fileSystem.setup((f) => f.readFile(TypeMoq.It.isAny())).returns(() => Promise.resolve('')); workspace = TypeMoq.Mock.ofType(); workspace .setup((c) => c.onDidChangeWorkspaceFolders(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())) @@ -51,7 +47,6 @@ suite('Terminal - Code Execution Manager', () => { commandManager.object, documentManager.object, disposables, - fileSystem.object, configService.object, serviceContainer.object, );