提交 58987c21 编写于 作者: I isidor

Fix error when invoking `explorer.newFile` while explorer viewlet is collapsed

fixes #96196
上级 457ce3ff
......@@ -6,7 +6,7 @@
import 'vs/css!./media/explorerviewlet';
import { localize } from 'vs/nls';
import * as DOM from 'vs/base/browser/dom';
import { VIEWLET_ID, ExplorerViewletVisibleContext, IFilesConfiguration, OpenEditorsVisibleContext } from 'vs/workbench/contrib/files/common/files';
import { VIEWLET_ID, ExplorerViewletVisibleContext, IFilesConfiguration, OpenEditorsVisibleContext, VIEW_ID } from 'vs/workbench/contrib/files/common/files';
import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet';
import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
import { ExplorerView } from 'vs/workbench/contrib/files/browser/views/explorerView';
......@@ -136,7 +136,7 @@ export class ExplorerViewletViewsContribution extends Disposable implements IWor
private createExplorerViewDescriptor(): IViewDescriptor {
return {
id: ExplorerView.ID,
id: VIEW_ID,
name: localize('folders', "Folders"),
containerIcon: Codicon.files.classNames,
ctorDescriptor: new SyncDescriptor(ExplorerView),
......@@ -191,7 +191,7 @@ export class ExplorerViewPaneContainer extends ViewPaneContainer {
}
protected createView(viewDescriptor: IViewDescriptor, options: IViewletViewOptions): ViewPane {
if (viewDescriptor.id === ExplorerView.ID) {
if (viewDescriptor.id === VIEW_ID) {
// Create a delegating editor service for the explorer to be able to delay the refresh in the opened
// editors view above. This is a workaround for being able to double click on a file to make it pinned
// without causing the animation in the opened editors view to kick in and change scroll position.
......@@ -232,7 +232,7 @@ export class ExplorerViewPaneContainer extends ViewPaneContainer {
}
public getExplorerView(): ExplorerView {
return <ExplorerView>this.getView(ExplorerView.ID);
return <ExplorerView>this.getView(VIEW_ID);
}
public getOpenEditorsView(): OpenEditorsView {
......@@ -245,7 +245,7 @@ export class ExplorerViewPaneContainer extends ViewPaneContainer {
}
focus(): void {
const explorerView = this.getView(ExplorerView.ID);
const explorerView = this.getView(VIEW_ID);
if (explorerView?.isExpanded()) {
explorerView.focus();
} else {
......
......@@ -13,7 +13,7 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
import * as strings from 'vs/base/common/strings';
import { Action } from 'vs/base/common/actions';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import { VIEWLET_ID, IExplorerService, IFilesConfiguration } from 'vs/workbench/contrib/files/common/files';
import { VIEWLET_ID, IExplorerService, IFilesConfiguration, VIEW_ID } from 'vs/workbench/contrib/files/common/files';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IFileService } from 'vs/platform/files/common/files';
import { toResource, SideBySideEditor, IEditorInput } from 'vs/workbench/common/editor';
......@@ -51,6 +51,7 @@ import { IEditorOptions } from 'vs/platform/editor/common/editor';
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
import { Codicon } from 'vs/base/common/codicons';
import { openEditorWith } from 'vs/workbench/contrib/files/common/openWith';
import { IViewsService } from 'vs/workbench/common/views';
export const NEW_FILE_COMMAND_ID = 'explorer.newFile';
export const NEW_FILE_LABEL = nls.localize('newFile', "New File");
......@@ -93,7 +94,6 @@ export class NewFileAction extends Action {
static readonly LABEL = nls.localize('createNewFile', "New File");
constructor(
@IExplorerService explorerService: IExplorerService,
@ICommandService private commandService: ICommandService
) {
super('explorer.newFile', NEW_FILE_LABEL);
......@@ -111,7 +111,6 @@ export class NewFolderAction extends Action {
static readonly LABEL = nls.localize('createNewFolder', "New Folder");
constructor(
@IExplorerService explorerService: IExplorerService,
@ICommandService private commandService: ICommandService
) {
super('explorer.newFolder', NEW_FOLDER_LABEL);
......@@ -915,10 +914,10 @@ async function openExplorerAndCreate(accessor: ServicesAccessor, isFolder: boole
const fileService = accessor.get(IFileService);
const textFileService = accessor.get(ITextFileService);
const editorService = accessor.get(IEditorService);
const viewletService = accessor.get(IViewletService);
const viewsService = accessor.get(IViewsService);
const notificationService = accessor.get(INotificationService);
await viewletService.openViewlet(VIEWLET_ID, true);
await viewsService.openView(VIEW_ID, true);
const stats = explorerService.getContext(false);
const stat = stats.length > 0 ? stats[0] : undefined;
......
......@@ -123,7 +123,6 @@ export function getContext(focus: ExplorerItem[], selection: ExplorerItem[], res
}
export class ExplorerView extends ViewPane {
static readonly ID: string = 'workbench.explorer.fileView';
static readonly TREE_VIEW_STATE_STORAGE_KEY: string = 'workbench.explorer.treeViewState';
private tree!: WorkbenchCompressibleAsyncDataTree<ExplorerItem | ExplorerItem[], ExplorerItem, FuzzyScore>;
......
......@@ -28,6 +28,11 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
*/
export const VIEWLET_ID = 'workbench.view.explorer';
/**
* Explorer file view id.
*/
export const VIEW_ID = 'workbench.explorer.fileView';
/**
* Id of the default editor for open with.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册