editorActions.ts 50.5 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

6
import * as nls from 'vs/nls';
J
Johannes Rieken 已提交
7
import { Action } from 'vs/base/common/actions';
8
import { mixin } from 'vs/base/common/objects';
B
Benjamin Pasero 已提交
9
import { IEditorInput, EditorInput, IEditorIdentifier, ConfirmResult, IEditorCommandsContext, CloseDirection } from 'vs/workbench/common/editor';
J
Johannes Rieken 已提交
10 11
import { QuickOpenEntryGroup } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { EditorQuickOpenEntry, EditorQuickOpenEntryGroup, IEditorQuickOpenEntry, QuickOpenAction } from 'vs/workbench/browser/quickopen';
J
Johannes Rieken 已提交
12
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
13
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
B
Benjamin Pasero 已提交
14
import { IResourceInput } from 'vs/platform/editor/common/editor';
J
Johannes Rieken 已提交
15 16 17
import { IHistoryService } from 'vs/workbench/services/history/common/history';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { ICommandService } from 'vs/platform/commands/common/commands';
18
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
C
22768  
Cristian 已提交
19
import { IWindowsService } from 'vs/platform/windows/common/windows';
20
import { CLOSE_EDITOR_COMMAND_ID, NAVIGATE_ALL_EDITORS_GROUP_PREFIX, MOVE_ACTIVE_EDITOR_COMMAND_ID, NAVIGATE_IN_ACTIVE_GROUP_PREFIX, ActiveEditorMoveArguments, SPLIT_EDITOR_LEFT, SPLIT_EDITOR_RIGHT, SPLIT_EDITOR_UP, SPLIT_EDITOR_DOWN, splitEditor, LAYOUT_EDITOR_GROUPS_COMMAND_ID, mergeAllGroups } from 'vs/workbench/browser/parts/editor/editorCommands';
21
import { IEditorGroupsService, IEditorGroup, GroupsArrangement, EditorsOrder, GroupLocation, GroupDirection, preferredSideBySideGroupDirection, IFindGroupScope, GroupOrientation, EditorGroupLayout, GroupsOrder } from 'vs/workbench/services/editor/common/editorGroupsService';
22
import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
B
Benjamin Pasero 已提交
23
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
24
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
E
Erich Gamma 已提交
25

26 27 28 29 30 31 32
export class ExecuteCommandAction extends Action {

	constructor(
		id: string,
		label: string,
		private commandId: string,
		private commandService: ICommandService,
33
		private commandArgs?: unknown
34 35 36 37
	) {
		super(id, label);
	}

J
Johannes Rieken 已提交
38
	run(): Promise<any> {
39 40 41 42
		return this.commandService.executeCommand(this.commandId, this.commandArgs);
	}
}

43
export class BaseSplitEditorAction extends Action {
44
	private toDispose: IDisposable[] = [];
45
	private direction: GroupDirection;
46

47 48 49
	constructor(
		id: string,
		label: string,
50 51
		protected editorGroupService: IEditorGroupsService,
		protected configurationService: IConfigurationService
52
	) {
53 54
		super(id, label);

55
		this.direction = this.getDirection();
56 57 58 59

		this.registerListeners();
	}

60 61 62 63
	protected getDirection(): GroupDirection {
		return preferredSideBySideGroupDirection(this.configurationService);
	}

64 65 66
	private registerListeners(): void {
		this.toDispose.push(this.configurationService.onDidChangeConfiguration(e => {
			if (e.affectsConfiguration('workbench.editor.openSideBySideDirection')) {
67
				this.direction = preferredSideBySideGroupDirection(this.configurationService);
68 69 70 71
			}
		}));
	}

B
Benjamin Pasero 已提交
72
	run(context?: IEditorIdentifier): Promise<any> {
73
		splitEditor(this.editorGroupService, this.direction, context);
74

B
Benjamin Pasero 已提交
75
		return Promise.resolve(true);
76 77
	}

B
Benjamin Pasero 已提交
78
	dispose(): void {
79 80 81
		super.dispose();

		this.toDispose = dispose(this.toDispose);
82 83 84
	}
}

85 86
export class SplitEditorAction extends BaseSplitEditorAction {

B
Benjamin Pasero 已提交
87 88
	static readonly ID = 'workbench.action.splitEditor';
	static readonly LABEL = nls.localize('splitEditor', "Split Editor");
89 90 91 92 93 94 95 96 97 98 99 100 101

	constructor(
		id: string,
		label: string,
		@IEditorGroupsService editorGroupService: IEditorGroupsService,
		@IConfigurationService configurationService: IConfigurationService
	) {
		super(id, label, editorGroupService, configurationService);
	}
}

export class SplitEditorOrthogonalAction extends BaseSplitEditorAction {

B
Benjamin Pasero 已提交
102 103
	static readonly ID = 'workbench.action.splitEditorOrthogonal';
	static readonly LABEL = nls.localize('splitEditorOrthogonal', "Split Editor Orthogonal");
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120

	constructor(
		id: string,
		label: string,
		@IEditorGroupsService editorGroupService: IEditorGroupsService,
		@IConfigurationService configurationService: IConfigurationService
	) {
		super(id, label, editorGroupService, configurationService);
	}

	protected getDirection(): GroupDirection {
		const direction = preferredSideBySideGroupDirection(this.configurationService);

		return direction === GroupDirection.RIGHT ? GroupDirection.DOWN : GroupDirection.RIGHT;
	}
}

121
export class SplitEditorLeftAction extends ExecuteCommandAction {
122

B
Benjamin Pasero 已提交
123 124
	static readonly ID = SPLIT_EDITOR_LEFT;
	static readonly LABEL = nls.localize('splitEditorGroupLeft', "Split Editor Left");
125 126 127 128

	constructor(
		id: string,
		label: string,
129
		@ICommandService commandService: ICommandService
130
	) {
131
		super(id, label, SPLIT_EDITOR_LEFT, commandService);
B
Benjamin Pasero 已提交
132 133 134
	}
}

135
export class SplitEditorRightAction extends ExecuteCommandAction {
B
Benjamin Pasero 已提交
136

B
Benjamin Pasero 已提交
137 138
	static readonly ID = SPLIT_EDITOR_RIGHT;
	static readonly LABEL = nls.localize('splitEditorGroupRight', "Split Editor Right");
B
Benjamin Pasero 已提交
139 140 141 142

	constructor(
		id: string,
		label: string,
143
		@ICommandService commandService: ICommandService
B
Benjamin Pasero 已提交
144
	) {
145
		super(id, label, SPLIT_EDITOR_RIGHT, commandService);
B
Benjamin Pasero 已提交
146 147 148
	}
}

149
export class SplitEditorUpAction extends ExecuteCommandAction {
B
Benjamin Pasero 已提交
150

B
Benjamin Pasero 已提交
151 152
	static readonly ID = SPLIT_EDITOR_UP;
	static readonly LABEL = nls.localize('splitEditorGroupUp', "Split Editor Up");
153

B
Benjamin Pasero 已提交
154 155 156
	constructor(
		id: string,
		label: string,
157
		@ICommandService commandService: ICommandService
B
Benjamin Pasero 已提交
158
	) {
159
		super(id, label, SPLIT_EDITOR_UP, commandService);
160
	}
B
Benjamin Pasero 已提交
161
}
162

163
export class SplitEditorDownAction extends ExecuteCommandAction {
164

B
Benjamin Pasero 已提交
165 166
	static readonly ID = SPLIT_EDITOR_DOWN;
	static readonly LABEL = nls.localize('splitEditorGroupDown', "Split Editor Down");
167

B
Benjamin Pasero 已提交
168 169 170
	constructor(
		id: string,
		label: string,
171
		@ICommandService commandService: ICommandService
B
Benjamin Pasero 已提交
172
	) {
173
		super(id, label, SPLIT_EDITOR_DOWN, commandService);
174 175 176
	}
}

177
export class JoinTwoGroupsAction extends Action {
I
initialshl 已提交
178

B
Benjamin Pasero 已提交
179 180
	static readonly ID = 'workbench.action.joinTwoGroups';
	static readonly LABEL = nls.localize('joinTwoGroups', "Join Editor Group with Next Group");
I
initialshl 已提交
181 182 183 184

	constructor(
		id: string,
		label: string,
185
		@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService
I
initialshl 已提交
186
	) {
187
		super(id, label);
I
initialshl 已提交
188 189
	}

B
Benjamin Pasero 已提交
190
	run(context?: IEditorIdentifier): Promise<any> {
B
Benjamin Pasero 已提交
191
		let sourceGroup: IEditorGroup | undefined;
B
Benjamin Pasero 已提交
192 193
		if (context && typeof context.groupId === 'number') {
			sourceGroup = this.editorGroupService.getGroup(context.groupId);
I
initialshl 已提交
194
		} else {
B
Benjamin Pasero 已提交
195
			sourceGroup = this.editorGroupService.activeGroup;
I
initialshl 已提交
196 197
		}

B
Benjamin Pasero 已提交
198 199 200 201 202 203
		if (sourceGroup) {
			const targetGroupDirections = [GroupDirection.RIGHT, GroupDirection.DOWN, GroupDirection.LEFT, GroupDirection.UP];
			for (const targetGroupDirection of targetGroupDirections) {
				const targetGroup = this.editorGroupService.findGroup({ direction: targetGroupDirection }, sourceGroup);
				if (targetGroup && sourceGroup !== targetGroup) {
					this.editorGroupService.mergeGroup(sourceGroup, targetGroup);
204

B
Benjamin Pasero 已提交
205 206
					return Promise.resolve(true);
				}
207
			}
B
Benjamin Pasero 已提交
208
		}
I
initialshl 已提交
209

B
Benjamin Pasero 已提交
210
		return Promise.resolve(true);
I
initialshl 已提交
211 212 213
	}
}

214 215
export class JoinAllGroupsAction extends Action {

B
Benjamin Pasero 已提交
216 217
	static readonly ID = 'workbench.action.joinAllGroups';
	static readonly LABEL = nls.localize('joinAllGroups', "Join All Editor Groups");
218 219 220 221

	constructor(
		id: string,
		label: string,
222
		@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService
223 224 225 226
	) {
		super(id, label);
	}

B
Benjamin Pasero 已提交
227
	run(context?: IEditorIdentifier): Promise<any> {
228
		mergeAllGroups(this.editorGroupService);
229

B
Benjamin Pasero 已提交
230
		return Promise.resolve(true);
231 232 233
	}
}

B
Benjamin Pasero 已提交
234
export class NavigateBetweenGroupsAction extends Action {
235

B
Benjamin Pasero 已提交
236 237
	static readonly ID = 'workbench.action.navigateEditorGroups';
	static readonly LABEL = nls.localize('navigateEditorGroups', "Navigate Between Editor Groups");
E
Erich Gamma 已提交
238

239 240 241
	constructor(
		id: string,
		label: string,
242
		@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService
243
	) {
E
Erich Gamma 已提交
244 245 246
		super(id, label);
	}

J
Johannes Rieken 已提交
247
	run(): Promise<any> {
B
Benjamin Pasero 已提交
248
		const nextGroup = this.editorGroupService.findGroup({ location: GroupLocation.NEXT }, this.editorGroupService.activeGroup, true);
B
Benjamin Pasero 已提交
249
		nextGroup.focus();
250

B
Benjamin Pasero 已提交
251
		return Promise.resolve(true);
E
Erich Gamma 已提交
252 253 254
	}
}

255 256
export class FocusActiveGroupAction extends Action {

B
Benjamin Pasero 已提交
257 258
	static readonly ID = 'workbench.action.focusActiveEditorGroup';
	static readonly LABEL = nls.localize('focusActiveEditorGroup', "Focus Active Editor Group");
259 260 261 262

	constructor(
		id: string,
		label: string,
263
		@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService
264 265 266 267
	) {
		super(id, label);
	}

J
Johannes Rieken 已提交
268
	run(): Promise<any> {
B
Benjamin Pasero 已提交
269
		this.editorGroupService.activeGroup.focus();
D
Daniel Imms 已提交
270

B
Benjamin Pasero 已提交
271
		return Promise.resolve(true);
E
Erich Gamma 已提交
272 273 274
	}
}

275
export abstract class BaseFocusGroupAction extends Action {
E
Erich Gamma 已提交
276 277 278 279

	constructor(
		id: string,
		label: string,
280
		private scope: IFindGroupScope,
281
		@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService
E
Erich Gamma 已提交
282 283 284 285
	) {
		super(id, label);
	}

J
Johannes Rieken 已提交
286
	run(): Promise<any> {
B
Benjamin Pasero 已提交
287
		const group = this.editorGroupService.findGroup(this.scope, this.editorGroupService.activeGroup, true);
288 289 290
		if (group) {
			group.focus();
		}
E
Erich Gamma 已提交
291

B
Benjamin Pasero 已提交
292
		return Promise.resolve(true);
E
Erich Gamma 已提交
293 294 295
	}
}

296 297
export class FocusFirstGroupAction extends BaseFocusGroupAction {

B
Benjamin Pasero 已提交
298 299
	static readonly ID = 'workbench.action.focusFirstEditorGroup';
	static readonly LABEL = nls.localize('focusFirstEditorGroup', "Focus First Editor Group");
300 301 302 303 304 305 306 307 308 309 310

	constructor(
		id: string,
		label: string,
		@IEditorGroupsService editorGroupService: IEditorGroupsService
	) {
		super(id, label, { location: GroupLocation.FIRST }, editorGroupService);
	}
}

export class FocusLastGroupAction extends BaseFocusGroupAction {
B
Benjamin Pasero 已提交
311

B
Benjamin Pasero 已提交
312 313
	static readonly ID = 'workbench.action.focusLastEditorGroup';
	static readonly LABEL = nls.localize('focusLastEditorGroup', "Focus Last Editor Group");
E
Erich Gamma 已提交
314 315 316 317

	constructor(
		id: string,
		label: string,
318
		@IEditorGroupsService editorGroupService: IEditorGroupsService
E
Erich Gamma 已提交
319
	) {
320
		super(id, label, { location: GroupLocation.LAST }, editorGroupService);
E
Erich Gamma 已提交
321
	}
322
}
E
Erich Gamma 已提交
323

324
export class FocusNextGroup extends BaseFocusGroupAction {
E
Erich Gamma 已提交
325

B
Benjamin Pasero 已提交
326 327
	static readonly ID = 'workbench.action.focusNextGroup';
	static readonly LABEL = nls.localize('focusNextGroup', "Focus Next Editor Group");
328 329 330 331 332 333 334

	constructor(
		id: string,
		label: string,
		@IEditorGroupsService editorGroupService: IEditorGroupsService
	) {
		super(id, label, { location: GroupLocation.NEXT }, editorGroupService);
E
Erich Gamma 已提交
335 336 337
	}
}

338
export class FocusPreviousGroup extends BaseFocusGroupAction {
339

B
Benjamin Pasero 已提交
340 341
	static readonly ID = 'workbench.action.focusPreviousGroup';
	static readonly LABEL = nls.localize('focusPreviousGroup', "Focus Previous Editor Group");
E
Erich Gamma 已提交
342

343 344 345
	constructor(
		id: string,
		label: string,
346
		@IEditorGroupsService editorGroupService: IEditorGroupsService
347
	) {
348
		super(id, label, { location: GroupLocation.PREVIOUS }, editorGroupService);
E
Erich Gamma 已提交
349
	}
350
}
E
Erich Gamma 已提交
351

352
export class FocusLeftGroup extends BaseFocusGroupAction {
E
Erich Gamma 已提交
353

B
Benjamin Pasero 已提交
354 355
	static readonly ID = 'workbench.action.focusLeftGroup';
	static readonly LABEL = nls.localize('focusLeftGroup', "Focus Left Editor Group");
356 357 358 359 360 361 362

	constructor(
		id: string,
		label: string,
		@IEditorGroupsService editorGroupService: IEditorGroupsService
	) {
		super(id, label, { direction: GroupDirection.LEFT }, editorGroupService);
E
Erich Gamma 已提交
363 364 365
	}
}

366
export class FocusRightGroup extends BaseFocusGroupAction {
367

B
Benjamin Pasero 已提交
368 369
	static readonly ID = 'workbench.action.focusRightGroup';
	static readonly LABEL = nls.localize('focusRightGroup', "Focus Right Editor Group");
370

E
Erich Gamma 已提交
371 372 373
	constructor(
		id: string,
		label: string,
374
		@IEditorGroupsService editorGroupService: IEditorGroupsService
E
Erich Gamma 已提交
375
	) {
376
		super(id, label, { direction: GroupDirection.RIGHT }, editorGroupService);
E
Erich Gamma 已提交
377
	}
378
}
E
Erich Gamma 已提交
379

380
export class FocusAboveGroup extends BaseFocusGroupAction {
E
Erich Gamma 已提交
381

B
Benjamin Pasero 已提交
382 383
	static readonly ID = 'workbench.action.focusAboveGroup';
	static readonly LABEL = nls.localize('focusAboveGroup', "Focus Above Editor Group");
384 385 386 387 388 389 390

	constructor(
		id: string,
		label: string,
		@IEditorGroupsService editorGroupService: IEditorGroupsService
	) {
		super(id, label, { direction: GroupDirection.UP }, editorGroupService);
E
Erich Gamma 已提交
391 392 393
	}
}

394 395
export class FocusBelowGroup extends BaseFocusGroupAction {

B
Benjamin Pasero 已提交
396 397
	static readonly ID = 'workbench.action.focusBelowGroup';
	static readonly LABEL = nls.localize('focusBelowGroup', "Focus Below Editor Group");
398 399 400 401 402 403 404 405 406 407

	constructor(
		id: string,
		label: string,
		@IEditorGroupsService editorGroupService: IEditorGroupsService
	) {
		super(id, label, { direction: GroupDirection.DOWN }, editorGroupService);
	}
}

408
export class OpenToSideFromQuickOpenAction extends Action {
E
Erich Gamma 已提交
409

B
Benjamin Pasero 已提交
410 411
	static readonly OPEN_TO_SIDE_ID = 'workbench.action.openToSide';
	static readonly OPEN_TO_SIDE_LABEL = nls.localize('openToSide', "Open to the Side");
E
Erich Gamma 已提交
412

413
	constructor(
414 415
		@IEditorService private readonly editorService: IEditorService,
		@IConfigurationService private readonly configurationService: IConfigurationService
416
	) {
417
		super(OpenToSideFromQuickOpenAction.OPEN_TO_SIDE_ID, OpenToSideFromQuickOpenAction.OPEN_TO_SIDE_LABEL);
E
Erich Gamma 已提交
418

419 420 421
		this.updateClass();
	}

B
Benjamin Pasero 已提交
422
	updateClass(): void {
423
		const preferredDirection = preferredSideBySideGroupDirection(this.configurationService);
E
Erich Gamma 已提交
424

425
		this.class = (preferredDirection === GroupDirection.RIGHT) ? 'quick-open-sidebyside-vertical' : 'quick-open-sidebyside-horizontal';
E
Erich Gamma 已提交
426 427
	}

J
Johannes Rieken 已提交
428
	run(context: any): Promise<any> {
B
Benjamin Pasero 已提交
429
		const entry = toEditorQuickOpenEntry(context);
E
Erich Gamma 已提交
430
		if (entry) {
431
			const input = entry.getInput();
432 433 434 435
			if (input) {
				if (input instanceof EditorInput) {
					return this.editorService.openEditor(input, entry.getOptions() || undefined, SIDE_GROUP);
				}
B
Benjamin Pasero 已提交
436

437 438
				const resourceInput = input as IResourceInput;
				resourceInput.options = mixin(resourceInput.options, entry.getOptions());
439

440 441
				return this.editorService.openEditor(resourceInput, SIDE_GROUP);
			}
E
Erich Gamma 已提交
442 443
		}

B
Benjamin Pasero 已提交
444
		return Promise.resolve(false);
E
Erich Gamma 已提交
445 446 447
	}
}

M
Matt Bierner 已提交
448
export function toEditorQuickOpenEntry(element: any): IEditorQuickOpenEntry | null {
E
Erich Gamma 已提交
449 450 451

	// QuickOpenEntryGroup
	if (element instanceof QuickOpenEntryGroup) {
B
Benjamin Pasero 已提交
452
		const group = element;
E
Erich Gamma 已提交
453 454 455 456 457 458 459 460 461 462 463 464 465 466
		if (group.getEntry()) {
			element = group.getEntry();
		}
	}

	// EditorQuickOpenEntry or EditorQuickOpenEntryGroup both implement IEditorQuickOpenEntry
	if (element instanceof EditorQuickOpenEntry || element instanceof EditorQuickOpenEntryGroup) {
		return element;
	}

	return null;
}

export class CloseEditorAction extends Action {
467

B
Benjamin Pasero 已提交
468 469
	static readonly ID = 'workbench.action.closeActiveEditor';
	static readonly LABEL = nls.localize('closeEditor', "Close Editor");
470

471 472 473
	constructor(
		id: string,
		label: string,
474
		@ICommandService private readonly commandService: ICommandService
475
	) {
I
isidor 已提交
476
		super(id, label, 'close-editor-action');
E
Erich Gamma 已提交
477 478
	}

B
Benjamin Pasero 已提交
479
	run(context?: IEditorCommandsContext): Promise<any> {
R
Rob Lourens 已提交
480
		return this.commandService.executeCommand(CLOSE_EDITOR_COMMAND_ID, undefined, context);
E
Erich Gamma 已提交
481 482 483
	}
}

484 485
export class CloseOneEditorAction extends Action {

B
Benjamin Pasero 已提交
486 487
	static readonly ID = 'workbench.action.closeActiveEditor';
	static readonly LABEL = nls.localize('closeOneEditor', "Close");
488 489 490 491

	constructor(
		id: string,
		label: string,
492
		@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService
493 494 495 496
	) {
		super(id, label, 'close-editor-action');
	}

J
Johannes Rieken 已提交
497
	run(context?: IEditorCommandsContext): Promise<any> {
M
Matt Bierner 已提交
498 499
		let group: IEditorGroup | undefined;
		let editorIndex: number | undefined;
500
		if (context) {
501
			group = this.editorGroupService.getGroup(context.groupId);
502

503
			if (group) {
M
Matt Bierner 已提交
504
				editorIndex = context.editorIndex!; // only allow editor at index if group is valid
505 506 507
			}
		}

508
		if (!group) {
509
			group = this.editorGroupService.activeGroup;
510 511
		}

512 513 514 515
		// Close specific editor in group
		if (typeof editorIndex === 'number') {
			const editorAtIndex = group.getEditor(editorIndex);
			if (editorAtIndex) {
516
				return group.closeEditor(editorAtIndex);
517 518 519 520 521
			}
		}

		// Otherwise close active editor in group
		if (group.activeEditor) {
522
			return group.closeEditor(group.activeEditor);
523 524
		}

B
Benjamin Pasero 已提交
525
		return Promise.resolve(false);
526 527 528
	}
}

M
misoguy 已提交
529 530
export class RevertAndCloseEditorAction extends Action {

B
Benjamin Pasero 已提交
531 532
	static readonly ID = 'workbench.action.revertAndCloseActiveEditor';
	static readonly LABEL = nls.localize('revertAndCloseActiveEditor', "Revert and Close Editor");
M
misoguy 已提交
533 534 535 536

	constructor(
		id: string,
		label: string,
537
		@IEditorService private readonly editorService: IEditorService
M
misoguy 已提交
538 539 540 541
	) {
		super(id, label);
	}

542
	async run(): Promise<any> {
B
Benjamin Pasero 已提交
543
		const activeControl = this.editorService.activeControl;
B
Benjamin Pasero 已提交
544
		if (activeControl) {
B
Benjamin Pasero 已提交
545
			const editor = activeControl.input;
546
			const group = activeControl.group;
B
Benjamin Pasero 已提交
547

548
			// first try a normal revert where the contents of the editor are restored
549 550 551
			try {
				await editor.revert();
			} catch (error) {
552 553 554 555
				// if that fails, since we are about to close the editor, we accept that
				// the editor cannot be reverted and instead do a soft revert that just
				// enables us to close the editor. With this, a user can always close a
				// dirty editor even when reverting fails.
556 557 558 559
				await editor.revert({ soft: true });
			}

			group.closeEditor(editor);
M
misoguy 已提交
560 561
		}

562
		return true;
M
misoguy 已提交
563 564 565
	}
}

B
Benjamin Pasero 已提交
566
export class CloseLeftEditorsInGroupAction extends Action {
567

B
Benjamin Pasero 已提交
568 569
	static readonly ID = 'workbench.action.closeEditorsToTheLeft';
	static readonly LABEL = nls.localize('closeEditorsToTheLeft', "Close Editors to the Left in Group");
570

571 572 573
	constructor(
		id: string,
		label: string,
574 575
		@IEditorService private readonly editorService: IEditorService,
		@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService
576
	) {
577 578 579
		super(id, label);
	}

J
Johannes Rieken 已提交
580
	run(context?: IEditorIdentifier): Promise<any> {
B
Benjamin Pasero 已提交
581
		const { group, editor } = getTarget(this.editorService, this.editorGroupService, context);
B
Benjamin Pasero 已提交
582 583
		if (group && editor) {
			return group.closeEditors({ direction: CloseDirection.LEFT, except: editor });
584 585
		}

B
Benjamin Pasero 已提交
586
		return Promise.resolve(false);
587 588 589
	}
}

B
Benjamin Pasero 已提交
590
function getTarget(editorService: IEditorService, editorGroupService: IEditorGroupsService, context?: IEditorIdentifier): { editor: IEditorInput | null, group: IEditorGroup | undefined } {
B
Benjamin Pasero 已提交
591 592 593 594 595 596 597 598
	if (context) {
		return { editor: context.editor, group: editorGroupService.getGroup(context.groupId) };
	}

	// Fallback to active group
	return { group: editorGroupService.activeGroup, editor: editorGroupService.activeGroup.activeEditor };
}

599
export abstract class BaseCloseAllAction extends Action {
600

601 602 603
	constructor(
		id: string,
		label: string,
M
Matt Bierner 已提交
604
		clazz: string | undefined,
605 606
		private textFileService: ITextFileService,
		protected editorGroupService: IEditorGroupsService
607
	) {
608
		super(id, label, clazz);
E
Erich Gamma 已提交
609 610
	}

611 612 613 614 615 616 617 618 619 620 621 622 623 624
	protected get groupsToClose(): IEditorGroup[] {
		const groupsToClose: IEditorGroup[] = [];

		// Close editors in reverse order of their grid appearance so that the editor
		// group that is the first (top-left) remains. This helps to keep view state
		// for editors around that have been opened in this visually first group.
		const groups = this.editorGroupService.getGroups(GroupsOrder.GRID_APPEARANCE);
		for (let i = groups.length - 1; i >= 0; i--) {
			groupsToClose.push(groups[i]);
		}

		return groupsToClose;
	}

625
	async run(): Promise<any> {
626 627 628

		// Just close all if there are no or one dirty editor
		if (this.textFileService.getDirty().length < 2) {
629
			return this.doCloseAll();
630 631 632
		}

		// Otherwise ask for combined confirmation
633 634 635 636
		const confirm = await this.textFileService.confirmSave();
		if (confirm === ConfirmResult.CANCEL) {
			return;
		}
637

638 639 640 641 642 643 644 645
		let saveOrRevert: boolean;
		if (confirm === ConfirmResult.DONT_SAVE) {
			await this.textFileService.revertAll(undefined, { soft: true });
			saveOrRevert = true;
		} else {
			const res = await this.textFileService.saveAll(true);
			saveOrRevert = res.results.every(r => !!r.success);
		}
646

647 648 649
		if (saveOrRevert) {
			return this.doCloseAll();
		}
E
Erich Gamma 已提交
650
	}
651

J
Johannes Rieken 已提交
652
	protected abstract doCloseAll(): Promise<any>;
653 654 655 656
}

export class CloseAllEditorsAction extends BaseCloseAllAction {

B
Benjamin Pasero 已提交
657 658
	static readonly ID = 'workbench.action.closeAllEditors';
	static readonly LABEL = nls.localize('closeAllEditors', "Close All Editors");
659 660 661 662 663

	constructor(
		id: string,
		label: string,
		@ITextFileService textFileService: ITextFileService,
664
		@IEditorGroupsService editorGroupService: IEditorGroupsService
665
	) {
666
		super(id, label, 'action-close-all-files', textFileService, editorGroupService);
667 668
	}

B
Benjamin Pasero 已提交
669
	protected doCloseAll(): Promise<any> {
I
isidor 已提交
670
		return Promise.all(this.groupsToClose.map(g => g.closeAllEditors()));
671 672 673 674 675
	}
}

export class CloseAllEditorGroupsAction extends BaseCloseAllAction {

B
Benjamin Pasero 已提交
676 677
	static readonly ID = 'workbench.action.closeAllGroups';
	static readonly LABEL = nls.localize('closeAllGroups', "Close All Editor Groups");
678 679 680 681 682

	constructor(
		id: string,
		label: string,
		@ITextFileService textFileService: ITextFileService,
683
		@IEditorGroupsService editorGroupService: IEditorGroupsService
684
	) {
R
Rob Lourens 已提交
685
		super(id, label, undefined, textFileService, editorGroupService);
686 687
	}

688 689 690 691
	protected async doCloseAll(): Promise<any> {
		await Promise.all(this.groupsToClose.map(group => group.closeAllEditors()));

		this.groupsToClose.forEach(group => this.editorGroupService.removeGroup(group));
692
	}
E
Erich Gamma 已提交
693 694
}

695 696
export class CloseEditorsInOtherGroupsAction extends Action {

B
Benjamin Pasero 已提交
697 698
	static readonly ID = 'workbench.action.closeEditorsInOtherGroups';
	static readonly LABEL = nls.localize('closeEditorsInOtherGroups', "Close Editors in Other Groups");
699

700 701 702
	constructor(
		id: string,
		label: string,
703
		@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
704
	) {
705 706 707
		super(id, label);
	}

J
Johannes Rieken 已提交
708
	run(context?: IEditorIdentifier): Promise<any> {
I
isidor 已提交
709
		const groupToSkip = context ? this.editorGroupService.getGroup(context.groupId) : this.editorGroupService.activeGroup;
I
isidor 已提交
710
		return Promise.all(this.editorGroupService.getGroups(GroupsOrder.MOST_RECENTLY_ACTIVE).map(g => {
B
Benjamin Pasero 已提交
711
			if (groupToSkip && g.id === groupToSkip.id) {
712
				return Promise.resolve();
713 714
			}

I
isidor 已提交
715 716
			return g.closeAllEditors();
		}));
717 718 719
	}
}

B
Benjamin Pasero 已提交
720 721 722 723 724 725 726 727
export class CloseEditorInAllGroupsAction extends Action {

	static readonly ID = 'workbench.action.closeEditorInAllGroups';
	static readonly LABEL = nls.localize('closeEditorInAllGroups', "Close Editor in All Groups");

	constructor(
		id: string,
		label: string,
728 729
		@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
		@IEditorService private readonly editorService: IEditorService
B
Benjamin Pasero 已提交
730 731 732 733
	) {
		super(id, label);
	}

J
Johannes Rieken 已提交
734
	run(): Promise<any> {
B
Benjamin Pasero 已提交
735 736
		const activeEditor = this.editorService.activeEditor;
		if (activeEditor) {
I
isidor 已提交
737
			return Promise.all(this.editorGroupService.getGroups(GroupsOrder.MOST_RECENTLY_ACTIVE).map(g => g.closeEditor(activeEditor)));
B
Benjamin Pasero 已提交
738 739
		}

740
		return Promise.resolve();
B
Benjamin Pasero 已提交
741 742 743
	}
}

744
export class BaseMoveGroupAction extends Action {
745

746 747 748
	constructor(
		id: string,
		label: string,
B
Benjamin Pasero 已提交
749
		private direction: GroupDirection,
750
		private editorGroupService: IEditorGroupsService
751
	) {
E
Erich Gamma 已提交
752 753 754
		super(id, label);
	}

B
Benjamin Pasero 已提交
755
	run(context?: IEditorIdentifier): Promise<any> {
B
Benjamin Pasero 已提交
756
		let sourceGroup: IEditorGroup | undefined;
757 758 759 760
		if (context && typeof context.groupId === 'number') {
			sourceGroup = this.editorGroupService.getGroup(context.groupId);
		} else {
			sourceGroup = this.editorGroupService.activeGroup;
761 762
		}

B
Benjamin Pasero 已提交
763 764 765 766 767
		if (sourceGroup) {
			const targetGroup = this.findTargetGroup(sourceGroup);
			if (targetGroup) {
				this.editorGroupService.moveGroup(sourceGroup, targetGroup, this.direction);
			}
E
Erich Gamma 已提交
768 769
		}

B
Benjamin Pasero 已提交
770
		return Promise.resolve(true);
E
Erich Gamma 已提交
771
	}
B
Benjamin Pasero 已提交
772

M
Matt Bierner 已提交
773
	private findTargetGroup(sourceGroup: IEditorGroup): IEditorGroup | undefined {
B
Benjamin Pasero 已提交
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789
		const targetNeighbours: GroupDirection[] = [this.direction];

		// Allow the target group to be in alternative locations to support more
		// scenarios of moving the group to the taret location.
		// Helps for https://github.com/Microsoft/vscode/issues/50741
		switch (this.direction) {
			case GroupDirection.LEFT:
			case GroupDirection.RIGHT:
				targetNeighbours.push(GroupDirection.UP, GroupDirection.DOWN);
				break;
			case GroupDirection.UP:
			case GroupDirection.DOWN:
				targetNeighbours.push(GroupDirection.LEFT, GroupDirection.RIGHT);
				break;
		}

790 791 792 793
		for (const targetNeighbour of targetNeighbours) {
			const targetNeighbourGroup = this.editorGroupService.findGroup({ direction: targetNeighbour }, sourceGroup);
			if (targetNeighbourGroup) {
				return targetNeighbourGroup;
B
Benjamin Pasero 已提交
794 795 796
			}
		}

R
Rob Lourens 已提交
797
		return undefined;
B
Benjamin Pasero 已提交
798
	}
E
Erich Gamma 已提交
799 800
}

801 802
export class MoveGroupLeftAction extends BaseMoveGroupAction {

B
Benjamin Pasero 已提交
803 804
	static readonly ID = 'workbench.action.moveActiveEditorGroupLeft';
	static readonly LABEL = nls.localize('moveActiveGroupLeft', "Move Editor Group Left");
805 806 807 808

	constructor(
		id: string,
		label: string,
809
		@IEditorGroupsService editorGroupService: IEditorGroupsService
810
	) {
B
Benjamin Pasero 已提交
811
		super(id, label, GroupDirection.LEFT, editorGroupService);
812 813 814 815
	}
}

export class MoveGroupRightAction extends BaseMoveGroupAction {
E
Erich Gamma 已提交
816

B
Benjamin Pasero 已提交
817 818
	static readonly ID = 'workbench.action.moveActiveEditorGroupRight';
	static readonly LABEL = nls.localize('moveActiveGroupRight', "Move Editor Group Right");
819

820 821 822
	constructor(
		id: string,
		label: string,
823
		@IEditorGroupsService editorGroupService: IEditorGroupsService
824
	) {
B
Benjamin Pasero 已提交
825
		super(id, label, GroupDirection.RIGHT, editorGroupService);
826 827
	}
}
828

829
export class MoveGroupUpAction extends BaseMoveGroupAction {
830

B
Benjamin Pasero 已提交
831 832
	static readonly ID = 'workbench.action.moveActiveEditorGroupUp';
	static readonly LABEL = nls.localize('moveActiveGroupUp', "Move Editor Group Up");
E
Erich Gamma 已提交
833

834 835 836
	constructor(
		id: string,
		label: string,
837
		@IEditorGroupsService editorGroupService: IEditorGroupsService
838
	) {
B
Benjamin Pasero 已提交
839
		super(id, label, GroupDirection.UP, editorGroupService);
840 841 842 843 844
	}
}

export class MoveGroupDownAction extends BaseMoveGroupAction {

B
Benjamin Pasero 已提交
845 846
	static readonly ID = 'workbench.action.moveActiveEditorGroupDown';
	static readonly LABEL = nls.localize('moveActiveGroupDown', "Move Editor Group Down");
847 848 849 850

	constructor(
		id: string,
		label: string,
851
		@IEditorGroupsService editorGroupService: IEditorGroupsService
852
	) {
B
Benjamin Pasero 已提交
853
		super(id, label, GroupDirection.DOWN, editorGroupService);
E
Erich Gamma 已提交
854 855 856
	}
}

857
export class MinimizeOtherGroupsAction extends Action {
E
Erich Gamma 已提交
858

B
Benjamin Pasero 已提交
859 860
	static readonly ID = 'workbench.action.minimizeOtherEditors';
	static readonly LABEL = nls.localize('minimizeOtherEditorGroups', "Maximize Editor Group");
861

862
	constructor(id: string, label: string, @IEditorGroupsService private readonly editorGroupService: IEditorGroupsService) {
E
Erich Gamma 已提交
863 864 865
		super(id, label);
	}

J
Johannes Rieken 已提交
866
	run(): Promise<any> {
867
		this.editorGroupService.arrangeGroups(GroupsArrangement.MINIMIZE_OTHERS);
E
Erich Gamma 已提交
868

B
Benjamin Pasero 已提交
869
		return Promise.resolve(false);
E
Erich Gamma 已提交
870 871 872
	}
}

B
Benjamin Pasero 已提交
873
export class ResetGroupSizesAction extends Action {
E
Erich Gamma 已提交
874

B
Benjamin Pasero 已提交
875 876
	static readonly ID = 'workbench.action.evenEditorWidths';
	static readonly LABEL = nls.localize('evenEditorGroups', "Reset Editor Group Sizes");
877

878
	constructor(id: string, label: string, @IEditorGroupsService private readonly editorGroupService: IEditorGroupsService) {
E
Erich Gamma 已提交
879 880 881
		super(id, label);
	}

J
Johannes Rieken 已提交
882
	run(): Promise<any> {
883
		this.editorGroupService.arrangeGroups(GroupsArrangement.EVEN);
E
Erich Gamma 已提交
884

B
Benjamin Pasero 已提交
885
		return Promise.resolve(false);
E
Erich Gamma 已提交
886 887 888
	}
}

889
export class MaximizeGroupAction extends Action {
890

B
Benjamin Pasero 已提交
891
	static readonly ID = 'workbench.action.maximizeEditor';
I
isidor 已提交
892
	static readonly LABEL = nls.localize('maximizeEditor', "Maximize Editor Group and Hide Side Bar");
893

894 895 896
	constructor(
		id: string,
		label: string,
897 898
		@IEditorService private readonly editorService: IEditorService,
		@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
899
		@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService
900 901 902 903
	) {
		super(id, label);
	}

J
Johannes Rieken 已提交
904
	run(): Promise<any> {
905 906
		if (this.editorService.activeEditor) {
			this.editorGroupService.arrangeGroups(GroupsArrangement.MINIMIZE_OTHERS);
907
			this.layoutService.setSideBarHidden(true);
908 909
		}

B
Benjamin Pasero 已提交
910
		return Promise.resolve(false);
911 912 913
	}
}

914 915
export abstract class BaseNavigateEditorAction extends Action {

916 917 918
	constructor(
		id: string,
		label: string,
919 920
		protected editorGroupService: IEditorGroupsService,
		protected editorService: IEditorService
921
	) {
922 923 924
		super(id, label);
	}

J
Johannes Rieken 已提交
925
	run(): Promise<any> {
926
		const result = this.navigate();
927
		if (!result) {
B
Benjamin Pasero 已提交
928
			return Promise.resolve(false);
929 930
		}

931 932
		const { groupId, editor } = result;
		if (!editor) {
B
Benjamin Pasero 已提交
933
			return Promise.resolve(false);
934 935 936
		}

		const group = this.editorGroupService.getGroup(groupId);
B
Benjamin Pasero 已提交
937 938 939 940 941
		if (group) {
			return group.openEditor(editor);
		}

		return Promise.resolve();
942 943
	}

M
Matt Bierner 已提交
944
	protected abstract navigate(): IEditorIdentifier | undefined;
945 946 947 948
}

export class OpenNextEditor extends BaseNavigateEditorAction {

B
Benjamin Pasero 已提交
949 950
	static readonly ID = 'workbench.action.nextEditor';
	static readonly LABEL = nls.localize('openNextEditor', "Open Next Editor");
951

952 953 954
	constructor(
		id: string,
		label: string,
955 956
		@IEditorGroupsService editorGroupService: IEditorGroupsService,
		@IEditorService editorService: IEditorService
957 958
	) {
		super(id, label, editorGroupService, editorService);
959 960
	}

M
Matt Bierner 已提交
961
	protected navigate(): IEditorIdentifier | undefined {
962 963 964 965

		// Navigate in active group if possible
		const activeGroup = this.editorGroupService.activeGroup;
		const activeGroupEditors = activeGroup.getEditors(EditorsOrder.SEQUENTIAL);
966
		const activeEditorIndex = activeGroup.activeEditor ? activeGroupEditors.indexOf(activeGroup.activeEditor) : -1;
967 968 969 970 971
		if (activeEditorIndex + 1 < activeGroupEditors.length) {
			return { editor: activeGroupEditors[activeEditorIndex + 1], groupId: activeGroup.id };
		}

		// Otherwise try in next group
B
Benjamin Pasero 已提交
972
		const nextGroup = this.editorGroupService.findGroup({ location: GroupLocation.NEXT }, this.editorGroupService.activeGroup, true);
973 974 975 976 977
		if (nextGroup) {
			const previousGroupEditors = nextGroup.getEditors(EditorsOrder.SEQUENTIAL);
			return { editor: previousGroupEditors[0], groupId: nextGroup.id };
		}

R
Rob Lourens 已提交
978
		return undefined;
979 980 981 982 983
	}
}

export class OpenPreviousEditor extends BaseNavigateEditorAction {

B
Benjamin Pasero 已提交
984 985
	static readonly ID = 'workbench.action.previousEditor';
	static readonly LABEL = nls.localize('openPreviousEditor', "Open Previous Editor");
986

987 988 989
	constructor(
		id: string,
		label: string,
990 991
		@IEditorGroupsService editorGroupService: IEditorGroupsService,
		@IEditorService editorService: IEditorService
992 993
	) {
		super(id, label, editorGroupService, editorService);
994 995
	}

M
Matt Bierner 已提交
996
	protected navigate(): IEditorIdentifier | undefined {
997 998 999 1000

		// Navigate in active group if possible
		const activeGroup = this.editorGroupService.activeGroup;
		const activeGroupEditors = activeGroup.getEditors(EditorsOrder.SEQUENTIAL);
1001
		const activeEditorIndex = activeGroup.activeEditor ? activeGroupEditors.indexOf(activeGroup.activeEditor) : -1;
1002 1003 1004 1005 1006
		if (activeEditorIndex > 0) {
			return { editor: activeGroupEditors[activeEditorIndex - 1], groupId: activeGroup.id };
		}

		// Otherwise try in previous group
B
Benjamin Pasero 已提交
1007
		const previousGroup = this.editorGroupService.findGroup({ location: GroupLocation.PREVIOUS }, this.editorGroupService.activeGroup, true);
1008 1009 1010 1011 1012
		if (previousGroup) {
			const previousGroupEditors = previousGroup.getEditors(EditorsOrder.SEQUENTIAL);
			return { editor: previousGroupEditors[previousGroupEditors.length - 1], groupId: previousGroup.id };
		}

R
Rob Lourens 已提交
1013
		return undefined;
1014 1015 1016 1017 1018
	}
}

export class OpenNextEditorInGroup extends BaseNavigateEditorAction {

B
Benjamin Pasero 已提交
1019 1020
	static readonly ID = 'workbench.action.nextEditorInGroup';
	static readonly LABEL = nls.localize('nextEditorInGroup', "Open Next Editor in Group");
1021 1022 1023 1024

	constructor(
		id: string,
		label: string,
1025 1026
		@IEditorGroupsService editorGroupService: IEditorGroupsService,
		@IEditorService editorService: IEditorService
1027 1028 1029 1030 1031
	) {
		super(id, label, editorGroupService, editorService);
	}

	protected navigate(): IEditorIdentifier {
1032 1033
		const group = this.editorGroupService.activeGroup;
		const editors = group.getEditors(EditorsOrder.SEQUENTIAL);
1034
		const index = group.activeEditor ? editors.indexOf(group.activeEditor) : -1;
1035 1036

		return { editor: index + 1 < editors.length ? editors[index + 1] : editors[0], groupId: group.id };
1037 1038 1039 1040 1041
	}
}

export class OpenPreviousEditorInGroup extends BaseNavigateEditorAction {

B
Benjamin Pasero 已提交
1042 1043
	static readonly ID = 'workbench.action.previousEditorInGroup';
	static readonly LABEL = nls.localize('openPreviousEditorInGroup', "Open Previous Editor in Group");
1044 1045 1046 1047

	constructor(
		id: string,
		label: string,
1048 1049
		@IEditorGroupsService editorGroupService: IEditorGroupsService,
		@IEditorService editorService: IEditorService
1050 1051 1052 1053 1054 1055 1056
	) {
		super(id, label, editorGroupService, editorService);
	}

	protected navigate(): IEditorIdentifier {
		const group = this.editorGroupService.activeGroup;
		const editors = group.getEditors(EditorsOrder.SEQUENTIAL);
1057
		const index = group.activeEditor ? editors.indexOf(group.activeEditor) : -1;
1058 1059 1060 1061 1062 1063 1064

		return { editor: index > 0 ? editors[index - 1] : editors[editors.length - 1], groupId: group.id };
	}
}

export class OpenFirstEditorInGroup extends BaseNavigateEditorAction {

B
Benjamin Pasero 已提交
1065 1066
	static readonly ID = 'workbench.action.firstEditorInGroup';
	static readonly LABEL = nls.localize('firstEditorInGroup', "Open First Editor in Group");
1067 1068 1069 1070

	constructor(
		id: string,
		label: string,
1071 1072
		@IEditorGroupsService editorGroupService: IEditorGroupsService,
		@IEditorService editorService: IEditorService
1073 1074 1075 1076 1077
	) {
		super(id, label, editorGroupService, editorService);
	}

	protected navigate(): IEditorIdentifier {
1078 1079 1080 1081
		const group = this.editorGroupService.activeGroup;
		const editors = group.getEditors(EditorsOrder.SEQUENTIAL);

		return { editor: editors[0], groupId: group.id };
1082
	}
B
Benjamin Pasero 已提交
1083 1084
}

1085 1086
export class OpenLastEditorInGroup extends BaseNavigateEditorAction {

B
Benjamin Pasero 已提交
1087 1088
	static readonly ID = 'workbench.action.lastEditorInGroup';
	static readonly LABEL = nls.localize('lastEditorInGroup', "Open Last Editor in Group");
1089 1090 1091 1092

	constructor(
		id: string,
		label: string,
1093 1094
		@IEditorGroupsService editorGroupService: IEditorGroupsService,
		@IEditorService editorService: IEditorService
1095 1096 1097 1098 1099
	) {
		super(id, label, editorGroupService, editorService);
	}

	protected navigate(): IEditorIdentifier {
1100 1101 1102 1103
		const group = this.editorGroupService.activeGroup;
		const editors = group.getEditors(EditorsOrder.SEQUENTIAL);

		return { editor: editors[editors.length - 1], groupId: group.id };
1104 1105 1106
	}
}

B
Benjamin Pasero 已提交
1107 1108
export class NavigateForwardAction extends Action {

B
Benjamin Pasero 已提交
1109 1110
	static readonly ID = 'workbench.action.navigateForward';
	static readonly LABEL = nls.localize('navigateNext', "Go Forward");
B
Benjamin Pasero 已提交
1111

1112
	constructor(id: string, label: string, @IHistoryService private readonly historyService: IHistoryService) {
B
Benjamin Pasero 已提交
1113 1114 1115
		super(id, label);
	}

J
Johannes Rieken 已提交
1116
	run(): Promise<any> {
B
Benjamin Pasero 已提交
1117 1118
		this.historyService.forward();

1119
		return Promise.resolve();
B
Benjamin Pasero 已提交
1120 1121 1122 1123 1124
	}
}

export class NavigateBackwardsAction extends Action {

B
Benjamin Pasero 已提交
1125 1126
	static readonly ID = 'workbench.action.navigateBack';
	static readonly LABEL = nls.localize('navigatePrevious', "Go Back");
B
Benjamin Pasero 已提交
1127

1128
	constructor(id: string, label: string, @IHistoryService private readonly historyService: IHistoryService) {
B
Benjamin Pasero 已提交
1129 1130 1131
		super(id, label);
	}

J
Johannes Rieken 已提交
1132
	run(): Promise<any> {
B
Benjamin Pasero 已提交
1133 1134
		this.historyService.back();

1135
		return Promise.resolve();
B
Benjamin Pasero 已提交
1136
	}
I
isidor 已提交
1137
}
1138

1139 1140 1141 1142 1143
export class NavigateToLastEditLocationAction extends Action {

	static readonly ID = 'workbench.action.navigateToLastEditLocation';
	static readonly LABEL = nls.localize('navigateToLastEditLocation', "Go to Last Edit Location");

1144
	constructor(id: string, label: string, @IHistoryService private readonly historyService: IHistoryService) {
1145 1146 1147
		super(id, label);
	}

J
Johannes Rieken 已提交
1148
	run(): Promise<any> {
1149 1150
		this.historyService.openLastEditLocation();

1151
		return Promise.resolve();
1152 1153 1154
	}
}

1155 1156
export class NavigateLastAction extends Action {

B
Benjamin Pasero 已提交
1157 1158
	static readonly ID = 'workbench.action.navigateLast';
	static readonly LABEL = nls.localize('navigateLast', "Go Last");
1159

1160
	constructor(id: string, label: string, @IHistoryService private readonly historyService: IHistoryService) {
1161 1162 1163
		super(id, label);
	}

J
Johannes Rieken 已提交
1164
	run(): Promise<any> {
1165 1166
		this.historyService.last();

1167
		return Promise.resolve();
1168 1169 1170
	}
}

1171 1172
export class ReopenClosedEditorAction extends Action {

B
Benjamin Pasero 已提交
1173 1174
	static readonly ID = 'workbench.action.reopenClosedEditor';
	static readonly LABEL = nls.localize('reopenClosedEditor', "Reopen Closed Editor");
1175 1176 1177 1178

	constructor(
		id: string,
		label: string,
1179
		@IHistoryService private readonly historyService: IHistoryService
1180 1181 1182 1183
	) {
		super(id, label);
	}

J
Johannes Rieken 已提交
1184
	run(): Promise<any> {
1185
		this.historyService.reopenLastClosedEditor();
1186

B
Benjamin Pasero 已提交
1187
		return Promise.resolve(false);
1188
	}
B
Benjamin Pasero 已提交
1189 1190
}

1191
export class ClearRecentFilesAction extends Action {
C
22768  
Cristian 已提交
1192

B
Benjamin Pasero 已提交
1193 1194
	static readonly ID = 'workbench.action.clearRecentFiles';
	static readonly LABEL = nls.localize('clearRecentFiles', "Clear Recently Opened");
C
22768  
Cristian 已提交
1195 1196 1197 1198

	constructor(
		id: string,
		label: string,
1199 1200
		@IWindowsService private readonly windowsService: IWindowsService,
		@IHistoryService private readonly historyService: IHistoryService
C
22768  
Cristian 已提交
1201 1202 1203 1204
	) {
		super(id, label);
	}

J
Johannes Rieken 已提交
1205
	run(): Promise<any> {
B
Benjamin Pasero 已提交
1206 1207

		// Clear global recently opened
B
Benjamin Pasero 已提交
1208
		this.windowsService.clearRecentlyOpened();
C
22768  
Cristian 已提交
1209

B
Benjamin Pasero 已提交
1210 1211 1212
		// Clear workspace specific recently opened
		this.historyService.clearRecentlyOpened();

B
Benjamin Pasero 已提交
1213
		return Promise.resolve(false);
C
22768  
Cristian 已提交
1214 1215 1216
	}
}

B
Benjamin Pasero 已提交
1217
export class ShowEditorsInActiveGroupAction extends QuickOpenAction {
B
Benjamin Pasero 已提交
1218

B
Benjamin Pasero 已提交
1219 1220
	static readonly ID = 'workbench.action.showEditorsInActiveGroup';
	static readonly LABEL = nls.localize('showEditorsInActiveGroup', "Show Editors in Active Group");
B
Benjamin Pasero 已提交
1221

1222 1223 1224
	constructor(
		actionId: string,
		actionLabel: string,
1225
		@IQuickOpenService quickOpenService: IQuickOpenService
1226
	) {
B
Benjamin Pasero 已提交
1227
		super(actionId, actionLabel, NAVIGATE_IN_ACTIVE_GROUP_PREFIX, quickOpenService);
1228
	}
B
Benjamin Pasero 已提交
1229 1230
}

B
Benjamin Pasero 已提交
1231 1232
export class ShowAllEditorsAction extends QuickOpenAction {

B
Benjamin Pasero 已提交
1233 1234
	static readonly ID = 'workbench.action.showAllEditors';
	static readonly LABEL = nls.localize('showAllEditors', "Show All Editors");
B
Benjamin Pasero 已提交
1235 1236 1237 1238 1239 1240

	constructor(actionId: string, actionLabel: string, @IQuickOpenService quickOpenService: IQuickOpenService) {
		super(actionId, actionLabel, NAVIGATE_ALL_EDITORS_GROUP_PREFIX, quickOpenService);
	}
}

1241
export class BaseQuickOpenEditorInGroupAction extends Action {
B
Benjamin Pasero 已提交
1242 1243 1244 1245

	constructor(
		id: string,
		label: string,
1246 1247
		@IQuickOpenService private readonly quickOpenService: IQuickOpenService,
		@IKeybindingService private readonly keybindingService: IKeybindingService
B
Benjamin Pasero 已提交
1248 1249 1250 1251
	) {
		super(id, label);
	}

J
Johannes Rieken 已提交
1252
	run(): Promise<any> {
1253
		const keys = this.keybindingService.lookupKeybindings(this.id);
B
Benjamin Pasero 已提交
1254

1255

B
Benjamin Pasero 已提交
1256 1257

		this.quickOpenService.show(NAVIGATE_IN_ACTIVE_GROUP_PREFIX, { quickNavigateConfiguration: { keybindings: keys } });
B
Benjamin Pasero 已提交
1258

B
Benjamin Pasero 已提交
1259
		return Promise.resolve(true);
B
Benjamin Pasero 已提交
1260 1261 1262
	}
}

1263 1264
export class OpenPreviousRecentlyUsedEditorInGroupAction extends BaseQuickOpenEditorInGroupAction {

B
Benjamin Pasero 已提交
1265 1266
	static readonly ID = 'workbench.action.openPreviousRecentlyUsedEditorInGroup';
	static readonly LABEL = nls.localize('openPreviousRecentlyUsedEditorInGroup', "Open Previous Recently Used Editor in Group");
1267 1268 1269 1270 1271

	constructor(
		id: string,
		label: string,
		@IQuickOpenService quickOpenService: IQuickOpenService,
B
Benjamin Pasero 已提交
1272
		@IKeybindingService keybindingService: IKeybindingService
1273
	) {
B
Benjamin Pasero 已提交
1274
		super(id, label, quickOpenService, keybindingService);
1275 1276 1277 1278 1279
	}
}

export class OpenNextRecentlyUsedEditorInGroupAction extends BaseQuickOpenEditorInGroupAction {

B
Benjamin Pasero 已提交
1280 1281
	static readonly ID = 'workbench.action.openNextRecentlyUsedEditorInGroup';
	static readonly LABEL = nls.localize('openNextRecentlyUsedEditorInGroup', "Open Next Recently Used Editor in Group");
1282 1283 1284 1285 1286

	constructor(
		id: string,
		label: string,
		@IQuickOpenService quickOpenService: IQuickOpenService,
B
Benjamin Pasero 已提交
1287
		@IKeybindingService keybindingService: IKeybindingService
1288
	) {
B
Benjamin Pasero 已提交
1289
		super(id, label, quickOpenService, keybindingService);
1290 1291 1292
	}
}

1293
export class OpenPreviousEditorFromHistoryAction extends Action {
B
Benjamin Pasero 已提交
1294

B
Benjamin Pasero 已提交
1295 1296
	static readonly ID = 'workbench.action.openPreviousEditorFromHistory';
	static readonly LABEL = nls.localize('navigateEditorHistoryByInput', "Open Previous Editor from History");
B
Benjamin Pasero 已提交
1297 1298 1299 1300

	constructor(
		id: string,
		label: string,
1301 1302
		@IQuickOpenService private readonly quickOpenService: IQuickOpenService,
		@IKeybindingService private readonly keybindingService: IKeybindingService
B
Benjamin Pasero 已提交
1303 1304 1305 1306
	) {
		super(id, label);
	}

J
Johannes Rieken 已提交
1307
	run(): Promise<any> {
1308
		const keys = this.keybindingService.lookupKeybindings(this.id);
B
Benjamin Pasero 已提交
1309

M
Matt Bierner 已提交
1310
		this.quickOpenService.show(undefined, { quickNavigateConfiguration: { keybindings: keys } });
B
Benjamin Pasero 已提交
1311

B
Benjamin Pasero 已提交
1312
		return Promise.resolve(true);
B
Benjamin Pasero 已提交
1313 1314 1315
	}
}

1316 1317
export class OpenNextRecentlyUsedEditorAction extends Action {

B
Benjamin Pasero 已提交
1318 1319
	static readonly ID = 'workbench.action.openNextRecentlyUsedEditor';
	static readonly LABEL = nls.localize('openNextRecentlyUsedEditor', "Open Next Recently Used Editor");
1320

1321
	constructor(id: string, label: string, @IHistoryService private readonly historyService: IHistoryService) {
1322 1323 1324
		super(id, label);
	}

J
Johannes Rieken 已提交
1325
	run(): Promise<any> {
1326 1327
		this.historyService.forward(true);

1328
		return Promise.resolve();
1329 1330 1331 1332 1333
	}
}

export class OpenPreviousRecentlyUsedEditorAction extends Action {

B
Benjamin Pasero 已提交
1334 1335
	static readonly ID = 'workbench.action.openPreviousRecentlyUsedEditor';
	static readonly LABEL = nls.localize('openPreviousRecentlyUsedEditor', "Open Previous Recently Used Editor");
1336

1337
	constructor(id: string, label: string, @IHistoryService private readonly historyService: IHistoryService) {
1338 1339 1340
		super(id, label);
	}

J
Johannes Rieken 已提交
1341
	run(): Promise<any> {
1342 1343
		this.historyService.back(true);

1344
		return Promise.resolve();
1345 1346 1347
	}
}

1348 1349
export class ClearEditorHistoryAction extends Action {

B
Benjamin Pasero 已提交
1350 1351
	static readonly ID = 'workbench.action.clearEditorHistory';
	static readonly LABEL = nls.localize('clearEditorHistory', "Clear Editor History");
1352 1353 1354 1355

	constructor(
		id: string,
		label: string,
1356
		@IHistoryService private readonly historyService: IHistoryService
1357 1358 1359 1360
	) {
		super(id, label);
	}

J
Johannes Rieken 已提交
1361
	run(): Promise<any> {
1362

1363
		// Editor history
1364 1365
		this.historyService.clear();

B
Benjamin Pasero 已提交
1366
		return Promise.resolve(true);
1367 1368 1369
	}
}

1370
export class MoveEditorLeftInGroupAction extends ExecuteCommandAction {
1371

B
Benjamin Pasero 已提交
1372 1373
	static readonly ID = 'workbench.action.moveEditorLeftInGroup';
	static readonly LABEL = nls.localize('moveEditorLeft', "Move Editor Left");
1374 1375 1376 1377

	constructor(
		id: string,
		label: string,
1378
		@ICommandService commandService: ICommandService
1379
	) {
1380
		super(id, label, MOVE_ACTIVE_EDITOR_COMMAND_ID, commandService, { to: 'left' } as ActiveEditorMoveArguments);
1381 1382 1383
	}
}

1384
export class MoveEditorRightInGroupAction extends ExecuteCommandAction {
1385

B
Benjamin Pasero 已提交
1386 1387
	static readonly ID = 'workbench.action.moveEditorRightInGroup';
	static readonly LABEL = nls.localize('moveEditorRight', "Move Editor Right");
1388 1389 1390 1391

	constructor(
		id: string,
		label: string,
1392
		@ICommandService commandService: ICommandService
1393
	) {
1394
		super(id, label, MOVE_ACTIVE_EDITOR_COMMAND_ID, commandService, { to: 'right' } as ActiveEditorMoveArguments);
1395 1396 1397
	}
}

1398
export class MoveEditorToPreviousGroupAction extends ExecuteCommandAction {
1399

B
Benjamin Pasero 已提交
1400 1401
	static readonly ID = 'workbench.action.moveEditorToPreviousGroup';
	static readonly LABEL = nls.localize('moveEditorToPreviousGroup', "Move Editor into Previous Group");
1402 1403 1404 1405

	constructor(
		id: string,
		label: string,
1406
		@ICommandService commandService: ICommandService
1407
	) {
1408
		super(id, label, MOVE_ACTIVE_EDITOR_COMMAND_ID, commandService, { to: 'previous', by: 'group' } as ActiveEditorMoveArguments);
1409
	}
1410
}
1411

1412
export class MoveEditorToNextGroupAction extends ExecuteCommandAction {
1413

B
Benjamin Pasero 已提交
1414 1415
	static readonly ID = 'workbench.action.moveEditorToNextGroup';
	static readonly LABEL = nls.localize('moveEditorToNextGroup', "Move Editor into Next Group");
1416 1417 1418 1419 1420 1421 1422

	constructor(
		id: string,
		label: string,
		@ICommandService commandService: ICommandService
	) {
		super(id, label, MOVE_ACTIVE_EDITOR_COMMAND_ID, commandService, { to: 'next', by: 'group' } as ActiveEditorMoveArguments);
1423 1424 1425
	}
}

1426
export class MoveEditorToAboveGroupAction extends ExecuteCommandAction {
1427

B
Benjamin Pasero 已提交
1428 1429
	static readonly ID = 'workbench.action.moveEditorToAboveGroup';
	static readonly LABEL = nls.localize('moveEditorToAboveGroup', "Move Editor into Above Group");
1430 1431 1432 1433

	constructor(
		id: string,
		label: string,
1434
		@ICommandService commandService: ICommandService
1435
	) {
1436
		super(id, label, MOVE_ACTIVE_EDITOR_COMMAND_ID, commandService, { to: 'up', by: 'group' } as ActiveEditorMoveArguments);
1437
	}
1438
}
1439

1440
export class MoveEditorToBelowGroupAction extends ExecuteCommandAction {
1441

B
Benjamin Pasero 已提交
1442 1443
	static readonly ID = 'workbench.action.moveEditorToBelowGroup';
	static readonly LABEL = nls.localize('moveEditorToBelowGroup', "Move Editor into Below Group");
1444 1445 1446 1447 1448 1449 1450

	constructor(
		id: string,
		label: string,
		@ICommandService commandService: ICommandService
	) {
		super(id, label, MOVE_ACTIVE_EDITOR_COMMAND_ID, commandService, { to: 'down', by: 'group' } as ActiveEditorMoveArguments);
1451 1452 1453
	}
}

1454
export class MoveEditorToLeftGroupAction extends ExecuteCommandAction {
1455

B
Benjamin Pasero 已提交
1456 1457
	static readonly ID = 'workbench.action.moveEditorToLeftGroup';
	static readonly LABEL = nls.localize('moveEditorToLeftGroup', "Move Editor into Left Group");
1458 1459 1460 1461

	constructor(
		id: string,
		label: string,
1462
		@ICommandService commandService: ICommandService
1463
	) {
1464
		super(id, label, MOVE_ACTIVE_EDITOR_COMMAND_ID, commandService, { to: 'left', by: 'group' } as ActiveEditorMoveArguments);
1465
	}
1466
}
1467

1468
export class MoveEditorToRightGroupAction extends ExecuteCommandAction {
1469

B
Benjamin Pasero 已提交
1470 1471
	static readonly ID = 'workbench.action.moveEditorToRightGroup';
	static readonly LABEL = nls.localize('moveEditorToRightGroup', "Move Editor into Right Group");
1472 1473 1474 1475 1476 1477 1478

	constructor(
		id: string,
		label: string,
		@ICommandService commandService: ICommandService
	) {
		super(id, label, MOVE_ACTIVE_EDITOR_COMMAND_ID, commandService, { to: 'right', by: 'group' } as ActiveEditorMoveArguments);
1479 1480 1481
	}
}

1482
export class MoveEditorToFirstGroupAction extends ExecuteCommandAction {
1483

B
Benjamin Pasero 已提交
1484 1485
	static readonly ID = 'workbench.action.moveEditorToFirstGroup';
	static readonly LABEL = nls.localize('moveEditorToFirstGroup', "Move Editor into First Group");
1486 1487 1488 1489

	constructor(
		id: string,
		label: string,
1490
		@ICommandService commandService: ICommandService
1491
	) {
1492
		super(id, label, MOVE_ACTIVE_EDITOR_COMMAND_ID, commandService, { to: 'first', by: 'group' } as ActiveEditorMoveArguments);
1493
	}
1494
}
1495

1496
export class MoveEditorToLastGroupAction extends ExecuteCommandAction {
1497

B
Benjamin Pasero 已提交
1498 1499
	static readonly ID = 'workbench.action.moveEditorToLastGroup';
	static readonly LABEL = nls.localize('moveEditorToLastGroup', "Move Editor into Last Group");
1500 1501 1502 1503 1504 1505 1506

	constructor(
		id: string,
		label: string,
		@ICommandService commandService: ICommandService
	) {
		super(id, label, MOVE_ACTIVE_EDITOR_COMMAND_ID, commandService, { to: 'last', by: 'group' } as ActiveEditorMoveArguments);
1507 1508 1509
	}
}

1510
export class EditorLayoutSingleAction extends ExecuteCommandAction {
1511

B
Benjamin Pasero 已提交
1512 1513
	static readonly ID = 'workbench.action.editorLayoutSingle';
	static readonly LABEL = nls.localize('editorLayoutSingle', "Single Column Editor Layout");
1514 1515 1516 1517

	constructor(
		id: string,
		label: string,
1518
		@ICommandService commandService: ICommandService
1519
	) {
1520
		super(id, label, LAYOUT_EDITOR_GROUPS_COMMAND_ID, commandService, { groups: [{}] } as EditorGroupLayout);
1521
	}
1522
}
1523

1524
export class EditorLayoutTwoColumnsAction extends ExecuteCommandAction {
1525

B
Benjamin Pasero 已提交
1526 1527
	static readonly ID = 'workbench.action.editorLayoutTwoColumns';
	static readonly LABEL = nls.localize('editorLayoutTwoColumns', "Two Columns Editor Layout");
1528 1529 1530 1531 1532 1533 1534

	constructor(
		id: string,
		label: string,
		@ICommandService commandService: ICommandService
	) {
		super(id, label, LAYOUT_EDITOR_GROUPS_COMMAND_ID, commandService, { groups: [{}, {}], orientation: GroupOrientation.HORIZONTAL } as EditorGroupLayout);
1535 1536 1537
	}
}

1538
export class EditorLayoutThreeColumnsAction extends ExecuteCommandAction {
1539

B
Benjamin Pasero 已提交
1540 1541
	static readonly ID = 'workbench.action.editorLayoutThreeColumns';
	static readonly LABEL = nls.localize('editorLayoutThreeColumns', "Three Columns Editor Layout");
1542 1543 1544 1545

	constructor(
		id: string,
		label: string,
1546
		@ICommandService commandService: ICommandService
1547
	) {
1548 1549 1550 1551 1552 1553
		super(id, label, LAYOUT_EDITOR_GROUPS_COMMAND_ID, commandService, { groups: [{}, {}, {}], orientation: GroupOrientation.HORIZONTAL } as EditorGroupLayout);
	}
}

export class EditorLayoutTwoRowsAction extends ExecuteCommandAction {

B
Benjamin Pasero 已提交
1554 1555
	static readonly ID = 'workbench.action.editorLayoutTwoRows';
	static readonly LABEL = nls.localize('editorLayoutTwoRows', "Two Rows Editor Layout");
1556 1557 1558 1559 1560 1561 1562

	constructor(
		id: string,
		label: string,
		@ICommandService commandService: ICommandService
	) {
		super(id, label, LAYOUT_EDITOR_GROUPS_COMMAND_ID, commandService, { groups: [{}, {}], orientation: GroupOrientation.VERTICAL } as EditorGroupLayout);
1563
	}
1564
}
1565

1566
export class EditorLayoutThreeRowsAction extends ExecuteCommandAction {
1567

B
Benjamin Pasero 已提交
1568 1569
	static readonly ID = 'workbench.action.editorLayoutThreeRows';
	static readonly LABEL = nls.localize('editorLayoutThreeRows', "Three Rows Editor Layout");
1570 1571 1572 1573 1574 1575 1576

	constructor(
		id: string,
		label: string,
		@ICommandService commandService: ICommandService
	) {
		super(id, label, LAYOUT_EDITOR_GROUPS_COMMAND_ID, commandService, { groups: [{}, {}, {}], orientation: GroupOrientation.VERTICAL } as EditorGroupLayout);
1577
	}
D
Daniel Imms 已提交
1578
}
1579

1580
export class EditorLayoutTwoByTwoGridAction extends ExecuteCommandAction {
1581

B
Benjamin Pasero 已提交
1582 1583
	static readonly ID = 'workbench.action.editorLayoutTwoByTwoGrid';
	static readonly LABEL = nls.localize('editorLayoutTwoByTwoGrid', "Grid Editor Layout (2x2)");
1584 1585 1586 1587

	constructor(
		id: string,
		label: string,
1588
		@ICommandService commandService: ICommandService
1589
	) {
1590
		super(id, label, LAYOUT_EDITOR_GROUPS_COMMAND_ID, commandService, { groups: [{ groups: [{}, {}] }, { groups: [{}, {}] }] } as EditorGroupLayout);
1591
	}
1592
}
1593

B
Benjamin Pasero 已提交
1594
export class EditorLayoutTwoColumnsBottomAction extends ExecuteCommandAction {
1595

B
Benjamin Pasero 已提交
1596 1597
	static readonly ID = 'workbench.action.editorLayoutTwoColumnsBottom';
	static readonly LABEL = nls.localize('editorLayoutTwoColumnsBottom', "Two Columns Bottom Editor Layout");
1598 1599 1600 1601 1602 1603

	constructor(
		id: string,
		label: string,
		@ICommandService commandService: ICommandService
	) {
B
Benjamin Pasero 已提交
1604
		super(id, label, LAYOUT_EDITOR_GROUPS_COMMAND_ID, commandService, { groups: [{}, { groups: [{}, {}] }], orientation: GroupOrientation.VERTICAL } as EditorGroupLayout);
1605 1606 1607
	}
}

B
Benjamin Pasero 已提交
1608
export class EditorLayoutTwoRowsRightAction extends ExecuteCommandAction {
1609

B
Benjamin Pasero 已提交
1610 1611
	static readonly ID = 'workbench.action.editorLayoutTwoRowsRight';
	static readonly LABEL = nls.localize('editorLayoutTwoRowsRight', "Two Rows Right Editor Layout");
1612 1613 1614 1615

	constructor(
		id: string,
		label: string,
1616
		@ICommandService commandService: ICommandService
1617
	) {
B
Benjamin Pasero 已提交
1618
		super(id, label, LAYOUT_EDITOR_GROUPS_COMMAND_ID, commandService, { groups: [{}, { groups: [{}, {}] }], orientation: GroupOrientation.HORIZONTAL } as EditorGroupLayout);
1619
	}
1620
}
1621

1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632
export class BaseCreateEditorGroupAction extends Action {

	constructor(
		id: string,
		label: string,
		private direction: GroupDirection,
		private editorGroupService: IEditorGroupsService
	) {
		super(id, label);
	}

J
Johannes Rieken 已提交
1633
	run(): Promise<any> {
1634 1635
		this.editorGroupService.addGroup(this.editorGroupService.activeGroup, this.direction, { activate: true });

B
Benjamin Pasero 已提交
1636
		return Promise.resolve(true);
1637 1638 1639 1640 1641
	}
}

export class NewEditorGroupLeftAction extends BaseCreateEditorGroupAction {

B
Benjamin Pasero 已提交
1642 1643
	static readonly ID = 'workbench.action.newGroupLeft';
	static readonly LABEL = nls.localize('newEditorLeft', "New Editor Group to the Left");
1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655

	constructor(
		id: string,
		label: string,
		@IEditorGroupsService editorGroupService: IEditorGroupsService
	) {
		super(id, label, GroupDirection.LEFT, editorGroupService);
	}
}

export class NewEditorGroupRightAction extends BaseCreateEditorGroupAction {

B
Benjamin Pasero 已提交
1656 1657
	static readonly ID = 'workbench.action.newGroupRight';
	static readonly LABEL = nls.localize('newEditorRight', "New Editor Group to the Right");
1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669

	constructor(
		id: string,
		label: string,
		@IEditorGroupsService editorGroupService: IEditorGroupsService
	) {
		super(id, label, GroupDirection.RIGHT, editorGroupService);
	}
}

export class NewEditorGroupAboveAction extends BaseCreateEditorGroupAction {

B
Benjamin Pasero 已提交
1670 1671
	static readonly ID = 'workbench.action.newGroupAbove';
	static readonly LABEL = nls.localize('newEditorAbove', "New Editor Group Above");
1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683

	constructor(
		id: string,
		label: string,
		@IEditorGroupsService editorGroupService: IEditorGroupsService
	) {
		super(id, label, GroupDirection.UP, editorGroupService);
	}
}

export class NewEditorGroupBelowAction extends BaseCreateEditorGroupAction {

B
Benjamin Pasero 已提交
1684 1685
	static readonly ID = 'workbench.action.newGroupBelow';
	static readonly LABEL = nls.localize('newEditorBelow', "New Editor Group Below");
1686 1687 1688 1689 1690 1691 1692 1693

	constructor(
		id: string,
		label: string,
		@IEditorGroupsService editorGroupService: IEditorGroupsService
	) {
		super(id, label, GroupDirection.DOWN, editorGroupService);
	}
I
isidor 已提交
1694
}