From 2e449867f32473940cc2ea0e29e37a52ebfb9547 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 14 Jun 2016 12:41:29 +0200 Subject: [PATCH] Split editor action does not show as disabled when limit hit (fixes #7651) --- .../browser/parts/editor/titleControl.ts | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/vs/workbench/browser/parts/editor/titleControl.ts b/src/vs/workbench/browser/parts/editor/titleControl.ts index f33b9f18c43..ac093418efe 100644 --- a/src/vs/workbench/browser/parts/editor/titleControl.ts +++ b/src/vs/workbench/browser/parts/editor/titleControl.ts @@ -89,7 +89,37 @@ export abstract class TitleControl { this.initActions(); } + private updateActionEnablement(): void { + if (!this.context) { + return; + } + + const group = this.context; + const groupCount = this.stacks.groups.length; + + // Move group + switch (this.stacks.positionOfGroup(group)) { + case Position.LEFT: + this.moveGroupLeftAction.enabled = false; + this.moveGroupRightAction.enabled = this.stacks.groups.length > 1; + break; + + case Position.CENTER: + this.moveGroupRightAction.enabled = this.stacks.groups.length > 2; + break; + + case Position.RIGHT: + this.moveGroupRightAction.enabled = false; + break; + } + + // Split editor + this.splitEditorAction.enabled = groupCount < 3; + } + private onSchedule(): void { + this.updateActionEnablement(); + if (this.refreshScheduled) { this.doRefresh(); } else { @@ -294,22 +324,6 @@ export abstract class TitleControl { primary.push(this.splitEditorAction); } - // Make sure enablement is good - switch (this.stacks.positionOfGroup(group)) { - case Position.LEFT: - this.moveGroupLeftAction.enabled = false; - this.moveGroupRightAction.enabled = this.stacks.groups.length > 1; - break; - - case Position.CENTER: - this.moveGroupRightAction.enabled = this.stacks.groups.length > 2; - break; - - case Position.RIGHT: - this.moveGroupRightAction.enabled = false; - break; - } - // Return actions const secondary = [ this.moveGroupLeftAction,