Skip to content

Commit

Permalink
feature: add setting whether or not to auto open a file after droppin…
Browse files Browse the repository at this point in the history
…g it into the explorer (microsoft#213498)

* feature: add setting whether or not to auto open a file after dropping it into the explorer

* use setting

* fix property

* format code

---------

Co-authored-by: Logan Ramos <[email protected]>
  • Loading branch information
SimonSiefke and lramos15 authored Jul 22, 2024
1 parent f792784 commit 3078b52
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/vs/workbench/contrib/files/browser/fileImportExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ export class ExternalFileImport {
});

// if we only add one file, just open it directly
if (resourceFileEdits.length === 1) {
const autoOpen = this.configurationService.getValue<IFilesConfiguration>().explorer.autoOpenDroppedFile;
if (autoOpen && resourceFileEdits.length === 1) {
const item = this.explorerService.findClosest(resourceFileEdits[0].newResource!);
if (item && !item.isDirectory) {
this.editorService.openEditor({ resource: item.resource, options: { pinned: true } });
Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/contrib/files/browser/files.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,11 @@ configurationRegistry.registerConfiguration({
description: nls.localize('explorer.incrementalNaming', "Controls which naming strategy to use when giving a new name to a duplicated Explorer item on paste."),
default: 'simple'
},
'explorer.autoOpenDroppedFile': {
'type': 'boolean',
'description': nls.localize('autoOpenDroppedFile', "Controls whether the Explorer should automatically open a file when it is dropped into the explorer"),
'default': true
},
'explorer.compactFolders': {
'type': 'boolean',
'description': nls.localize('compressSingleChildFolders', "Controls whether the Explorer should render folders in a compact form. In such a form, single child folders will be compressed in a combined tree element. Useful for Java package structures, for example."),
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/files/common/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export interface IFilesConfiguration extends PlatformIFilesConfiguration, IWorkb
expand: boolean;
patterns: { [parent: string]: string };
};
autoOpenDroppedFile: boolean;
};
editor: IEditorOptions;
}
Expand Down

0 comments on commit 3078b52

Please sign in to comment.