Skip to content

Commit b3d43e5

Browse files
author
Kartik Raj
authored
Do not open "save as" window when running existing Python files (#21232)
Closes #21209
1 parent b0da28c commit b3d43e5

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/client/common/application/types.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -852,15 +852,15 @@ export interface IWorkspaceService {
852852
*/
853853
openTextDocument(options?: { language?: string; content?: string }): Thenable<TextDocument>;
854854
/**
855-
* Saves the editor identified by the given resource to a new file name as provided by the user and
856-
* returns the resulting resource or `undefined` if save was not successful or cancelled.
855+
* Saves the editor identified by the given resource and returns the resulting resource or `undefined`
856+
* if save was not successful.
857857
*
858-
* **Note** that an editor with the provided resource must be opened in order to be saved as.
858+
* **Note** that an editor with the provided resource must be opened in order to be saved.
859859
*
860-
* @param uri the associated uri for the opened editor to save as.
861-
* @return A thenable that resolves when the save-as operation has finished.
860+
* @param uri the associated uri for the opened editor to save.
861+
* @return A thenable that resolves when the save operation has finished.
862862
*/
863-
saveAs(uri: Uri): Thenable<Uri | undefined>;
863+
save(uri: Uri): Thenable<Uri | undefined>;
864864
}
865865

866866
export const ITerminalManager = Symbol('ITerminalManager');

src/client/common/application/workspace.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ export class WorkspaceService implements IWorkspaceService {
113113
return `{${enabledSearchExcludes.join(',')}}`;
114114
}
115115

116-
public async saveAs(uri: Uri): Promise<Uri | undefined> {
116+
public async save(uri: Uri): Promise<Uri | undefined> {
117117
try {
118118
// This is a proposed API hence putting it inside try...catch.
119-
const result = await workspace.saveAs(uri);
119+
const result = await workspace.save(uri);
120120
return result;
121121
} catch (ex) {
122122
return undefined;

src/client/terminals/codeExecution/helper.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ export class CodeExecutionHelper implements ICodeExecutionHelper {
122122

123123
public async saveFileIfDirty(file: Uri): Promise<Resource> {
124124
const docs = this.documentManager.textDocuments.filter((d) => d.uri.path === file.path);
125-
if (docs.length === 1 && docs[0].isDirty) {
125+
if (docs.length === 1 && (docs[0].isDirty || docs[0].isUntitled)) {
126126
const workspaceService = this.serviceContainer.get<IWorkspaceService>(IWorkspaceService);
127-
return workspaceService.saveAs(docs[0].uri);
127+
return workspaceService.save(docs[0].uri);
128128
}
129129
return undefined;
130130
}

src/test/terminals/codeExecution/helper.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ suite('Terminal - Code Execution Helper', () => {
383383
const untitledUri = Uri.file('Untitled-1');
384384
document.setup((doc) => doc.uri).returns(() => untitledUri);
385385
const expectedSavedUri = Uri.file('one.py');
386-
workspaceService.setup((w) => w.saveAs(TypeMoq.It.isAny())).returns(() => Promise.resolve(expectedSavedUri));
386+
workspaceService.setup((w) => w.save(TypeMoq.It.isAny())).returns(() => Promise.resolve(expectedSavedUri));
387387

388388
const savedUri = await helper.saveFileIfDirty(untitledUri);
389389

0 commit comments

Comments
 (0)