提交 c7e23b4c 编写于 作者: J Joao Moreno

Merge branch 'master' of github.com:Microsoft/vscode

...@@ -353,16 +353,16 @@ export class VSCodeWindow { ...@@ -353,16 +353,16 @@ export class VSCodeWindow {
return this._readyState; return this._readyState;
} }
private registerNavigationListenerOn(command: 'swipe' | 'app-command', back: 'left' | 'browser-backward', forward: 'right' | 'browser-forward') { private registerNavigationListenerOn(command: 'swipe' | 'app-command', back: 'left' | 'browser-backward', forward: 'right' | 'browser-forward', acrossEditors: boolean) {
this._win.on(command, (e, cmd) => { this._win.on(command, (e, cmd) => {
if (this.readyState !== ReadyState.READY) { if (this.readyState !== ReadyState.READY) {
return; // window must be ready return; // window must be ready
} }
if (cmd === back) { if (cmd === back) {
this.send('vscode:runAction', 'workbench.action.navigateBack'); this.send('vscode:runAction', acrossEditors ? 'workbench.action.openPreviousRecentlyUsedEditor' : 'workbench.action.navigateBack');
} else if (cmd === forward) { } else if (cmd === forward) {
this.send('vscode:runAction', 'workbench.action.navigateForward'); this.send('vscode:runAction', acrossEditors ? 'workbench.action.openNextRecentlyUsedEditor' : 'workbench.action.navigateForward');
} }
}); });
} }
...@@ -393,7 +393,7 @@ export class VSCodeWindow { ...@@ -393,7 +393,7 @@ export class VSCodeWindow {
}); });
// App commands support // App commands support
this.registerNavigationListenerOn('app-command', 'browser-backward', 'browser-forward'); this.registerNavigationListenerOn('app-command', 'browser-backward', 'browser-forward', false);
// Handle code that wants to open links // Handle code that wants to open links
this._win.webContents.on('new-window', (event: Event, url: string) => { this._win.webContents.on('new-window', (event: Event, url: string) => {
...@@ -457,7 +457,7 @@ export class VSCodeWindow { ...@@ -457,7 +457,7 @@ export class VSCodeWindow {
if (platform.isMacintosh) { if (platform.isMacintosh) {
const config = this.configurationService.getConfiguration<IWorkbenchEditorConfiguration>(); const config = this.configurationService.getConfiguration<IWorkbenchEditorConfiguration>();
if (config && config.workbench && config.workbench.editor && config.workbench.editor.swipeToNavigate) { if (config && config.workbench && config.workbench.editor && config.workbench.editor.swipeToNavigate) {
this.registerNavigationListenerOn('swipe', 'left', 'right'); this.registerNavigationListenerOn('swipe', 'left', 'right', true);
} else { } else {
this._win.removeAllListeners('swipe'); this._win.removeAllListeners('swipe');
} }
......
...@@ -248,6 +248,11 @@ export interface IEditorOptions { ...@@ -248,6 +248,11 @@ export interface IEditorOptions {
*/ */
revealIfVisible?: boolean; revealIfVisible?: boolean;
/**
* Will reveal the editor if it is already opened (even when not visible) in any of the opened editor groups.
*/
revealIfOpened?: boolean;
/** /**
* An editor that is pinned remains in the editor stack even when another editor is being opened. * An editor that is pinned remains in the editor stack even when another editor is being opened.
* An editor that is not pinned will always get replaced by another editor that is not pinned. * An editor that is not pinned will always get replaced by another editor that is not pinned.
......
...@@ -32,7 +32,7 @@ import { ...@@ -32,7 +32,7 @@ import {
CloseEditorsInGroupAction, CloseEditorsInOtherGroupsAction, CloseAllEditorsAction, MoveGroupLeftAction, MoveGroupRightAction, SplitEditorAction, JoinTwoGroupsAction, KeepEditorAction, CloseOtherEditorsInGroupAction, OpenToSideAction, RevertAndCloseEditorAction, CloseEditorsInGroupAction, CloseEditorsInOtherGroupsAction, CloseAllEditorsAction, MoveGroupLeftAction, MoveGroupRightAction, SplitEditorAction, JoinTwoGroupsAction, KeepEditorAction, CloseOtherEditorsInGroupAction, OpenToSideAction, RevertAndCloseEditorAction,
NavigateBetweenGroupsAction, FocusActiveGroupAction, FocusFirstGroupAction, FocusSecondGroupAction, FocusThirdGroupAction, EvenGroupWidthsAction, MaximizeGroupAction, MinimizeOtherGroupsAction, FocusPreviousGroup, FocusNextGroup, ShowEditorsInGroupOneAction, NavigateBetweenGroupsAction, FocusActiveGroupAction, FocusFirstGroupAction, FocusSecondGroupAction, FocusThirdGroupAction, EvenGroupWidthsAction, MaximizeGroupAction, MinimizeOtherGroupsAction, FocusPreviousGroup, FocusNextGroup, ShowEditorsInGroupOneAction,
toEditorQuickOpenEntry, CloseLeftEditorsInGroupAction, CloseRightEditorsInGroupAction, OpenNextEditor, OpenPreviousEditor, NavigateBackwardsAction, NavigateForwardAction, ReopenClosedEditorAction, OpenPreviousRecentlyUsedEditorInGroupAction, NAVIGATE_IN_GROUP_ONE_PREFIX, toEditorQuickOpenEntry, CloseLeftEditorsInGroupAction, CloseRightEditorsInGroupAction, OpenNextEditor, OpenPreviousEditor, NavigateBackwardsAction, NavigateForwardAction, ReopenClosedEditorAction, OpenPreviousRecentlyUsedEditorInGroupAction, NAVIGATE_IN_GROUP_ONE_PREFIX,
OpenPreviousEditorFromHistoryAction, ShowAllEditorsAction, NAVIGATE_ALL_EDITORS_GROUP_PREFIX, ClearEditorHistoryAction, ShowEditorsInGroupTwoAction, MoveEditorRightInGroupAction, OpenNextEditorInGroup, OpenPreviousEditorInGroup, OpenPreviousEditorFromHistoryAction, ShowAllEditorsAction, NAVIGATE_ALL_EDITORS_GROUP_PREFIX, ClearEditorHistoryAction, ShowEditorsInGroupTwoAction, MoveEditorRightInGroupAction, OpenNextEditorInGroup, OpenPreviousEditorInGroup, OpenNextRecentlyUsedEditorAction, OpenPreviousRecentlyUsedEditorAction,
NAVIGATE_IN_GROUP_TWO_PREFIX, ShowEditorsInGroupThreeAction, NAVIGATE_IN_GROUP_THREE_PREFIX, FocusLastEditorInStackAction, OpenNextRecentlyUsedEditorInGroupAction, MoveEditorToPreviousGroupAction, MoveEditorToNextGroupAction, MoveEditorLeftInGroupAction, ClearRecentFilesAction NAVIGATE_IN_GROUP_TWO_PREFIX, ShowEditorsInGroupThreeAction, NAVIGATE_IN_GROUP_THREE_PREFIX, FocusLastEditorInStackAction, OpenNextRecentlyUsedEditorInGroupAction, MoveEditorToPreviousGroupAction, MoveEditorToNextGroupAction, MoveEditorLeftInGroupAction, ClearRecentFilesAction
} from 'vs/workbench/browser/parts/editor/editorActions'; } from 'vs/workbench/browser/parts/editor/editorActions';
import * as editorCommands from 'vs/workbench/browser/parts/editor/editorCommands'; import * as editorCommands from 'vs/workbench/browser/parts/editor/editorCommands';
...@@ -318,6 +318,8 @@ Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpen ...@@ -318,6 +318,8 @@ Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpen
const category = nls.localize('view', "View"); const category = nls.localize('view', "View");
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenNextEditorInGroup, OpenNextEditorInGroup.ID, OpenNextEditorInGroup.LABEL), 'View: Open Next Editor in Group', category); registry.registerWorkbenchAction(new SyncActionDescriptor(OpenNextEditorInGroup, OpenNextEditorInGroup.ID, OpenNextEditorInGroup.LABEL), 'View: Open Next Editor in Group', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenPreviousEditorInGroup, OpenPreviousEditorInGroup.ID, OpenPreviousEditorInGroup.LABEL), 'View: Open Next Recently Used Editor in Group', category); registry.registerWorkbenchAction(new SyncActionDescriptor(OpenPreviousEditorInGroup, OpenPreviousEditorInGroup.ID, OpenPreviousEditorInGroup.LABEL), 'View: Open Next Recently Used Editor in Group', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenNextRecentlyUsedEditorAction, OpenNextRecentlyUsedEditorAction.ID, OpenNextRecentlyUsedEditorAction.LABEL), 'View: Open Next Recently Used Editor');
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenPreviousRecentlyUsedEditorAction, OpenPreviousRecentlyUsedEditorAction.ID, OpenPreviousRecentlyUsedEditorAction.LABEL), 'View: Open Previous Recently Used Editor');
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenNextRecentlyUsedEditorInGroupAction, OpenNextRecentlyUsedEditorInGroupAction.ID, OpenNextRecentlyUsedEditorInGroupAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.Tab, mac: { primary: KeyMod.WinCtrl | KeyCode.Tab } }), 'Open Next Recently Used Editor in Group'); registry.registerWorkbenchAction(new SyncActionDescriptor(OpenNextRecentlyUsedEditorInGroupAction, OpenNextRecentlyUsedEditorInGroupAction.ID, OpenNextRecentlyUsedEditorInGroupAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.Tab, mac: { primary: KeyMod.WinCtrl | KeyCode.Tab } }), 'Open Next Recently Used Editor in Group');
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenPreviousRecentlyUsedEditorInGroupAction, OpenPreviousRecentlyUsedEditorInGroupAction.ID, OpenPreviousRecentlyUsedEditorInGroupAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Tab, mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.Tab } }), 'Open Previous Recently Used Editor in Group'); registry.registerWorkbenchAction(new SyncActionDescriptor(OpenPreviousRecentlyUsedEditorInGroupAction, OpenPreviousRecentlyUsedEditorInGroupAction.ID, OpenPreviousRecentlyUsedEditorInGroupAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Tab, mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.Tab } }), 'Open Previous Recently Used Editor in Group');
registry.registerWorkbenchAction(new SyncActionDescriptor(ShowAllEditorsAction, ShowAllEditorsAction.ID, ShowAllEditorsAction.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_P), mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Tab } }), 'View: Show All Editors', category); registry.registerWorkbenchAction(new SyncActionDescriptor(ShowAllEditorsAction, ShowAllEditorsAction.ID, ShowAllEditorsAction.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_P), mac: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Tab } }), 'View: Show All Editors', category);
......
...@@ -1321,6 +1321,38 @@ export class OpenPreviousEditorFromHistoryAction extends Action { ...@@ -1321,6 +1321,38 @@ export class OpenPreviousEditorFromHistoryAction extends Action {
} }
} }
export class OpenNextRecentlyUsedEditorAction extends Action {
public static ID = 'workbench.action.openNextRecentlyUsedEditor';
public static LABEL = nls.localize('openNextRecentlyUsedEditor', "Open Next Recently Used Editor");
constructor(id: string, label: string, @IHistoryService private historyService: IHistoryService) {
super(id, label);
}
public run(): TPromise<any> {
this.historyService.forward(true);
return TPromise.as(null);
}
}
export class OpenPreviousRecentlyUsedEditorAction extends Action {
public static ID = 'workbench.action.openPreviousRecentlyUsedEditor';
public static LABEL = nls.localize('openPreviousRecentlyUsedEditor', "Open Previous Recently Used Editor");
constructor(id: string, label: string, @IHistoryService private historyService: IHistoryService) {
super(id, label);
}
public run(): TPromise<any> {
this.historyService.back(true);
return TPromise.as(null);
}
}
export class ClearEditorHistoryAction extends Action { export class ClearEditorHistoryAction extends Action {
public static ID = 'workbench.action.clearEditorHistory'; public static ID = 'workbench.action.clearEditorHistory';
......
...@@ -1329,7 +1329,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService ...@@ -1329,7 +1329,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
// Respect option to reveal an editor if it is open (not necessarily visible) // Respect option to reveal an editor if it is open (not necessarily visible)
const skipRevealIfOpen = (options && options.index) || arg1 === true /* open to side */ || typeof arg1 === 'number' /* open specific group */; const skipRevealIfOpen = (options && options.index) || arg1 === true /* open to side */ || typeof arg1 === 'number' /* open specific group */;
if (!skipRevealIfOpen && this.revealIfOpen) { if (!skipRevealIfOpen && (this.revealIfOpen || (options && options.revealIfOpened))) {
const group = this.stacks.findGroup(input); const group = this.stacks.findGroup(input);
if (group) { if (group) {
return this.stacks.positionOfGroup(group); return this.stacks.positionOfGroup(group);
......
...@@ -513,6 +513,7 @@ export class EditorOptions implements IEditorOptions { ...@@ -513,6 +513,7 @@ export class EditorOptions implements IEditorOptions {
options.preserveFocus = settings.preserveFocus; options.preserveFocus = settings.preserveFocus;
options.forceOpen = settings.forceOpen; options.forceOpen = settings.forceOpen;
options.revealIfVisible = settings.revealIfVisible; options.revealIfVisible = settings.revealIfVisible;
options.revealIfOpened = settings.revealIfOpened;
options.pinned = settings.pinned; options.pinned = settings.pinned;
options.index = settings.index; options.index = settings.index;
options.inactive = settings.inactive; options.inactive = settings.inactive;
...@@ -528,6 +529,7 @@ export class EditorOptions implements IEditorOptions { ...@@ -528,6 +529,7 @@ export class EditorOptions implements IEditorOptions {
this.preserveFocus = other.preserveFocus; this.preserveFocus = other.preserveFocus;
this.forceOpen = other.forceOpen; this.forceOpen = other.forceOpen;
this.revealIfVisible = other.revealIfVisible; this.revealIfVisible = other.revealIfVisible;
this.revealIfOpened = other.revealIfOpened;
this.pinned = other.pinned; this.pinned = other.pinned;
this.index = other.index; this.index = other.index;
this.inactive = other.inactive; this.inactive = other.inactive;
...@@ -552,6 +554,11 @@ export class EditorOptions implements IEditorOptions { ...@@ -552,6 +554,11 @@ export class EditorOptions implements IEditorOptions {
*/ */
public revealIfVisible: boolean; public revealIfVisible: boolean;
/**
* Will reveal the editor if it is already opened (even when not visible) in any of the opened editor groups.
*/
public revealIfOpened: boolean;
/** /**
* An editor that is pinned remains in the editor stack even when another editor is being opened. * An editor that is pinned remains in the editor stack even when another editor is being opened.
* An editor that is not pinned will always get replaced by another editor that is not pinned. * An editor that is not pinned will always get replaced by another editor that is not pinned.
...@@ -586,7 +593,7 @@ export class TextEditorOptions extends EditorOptions { ...@@ -586,7 +593,7 @@ export class TextEditorOptions extends EditorOptions {
public static from(input: IBaseResourceInput): TextEditorOptions { public static from(input: IBaseResourceInput): TextEditorOptions {
let options: TextEditorOptions = null; let options: TextEditorOptions = null;
if (input && input.options) { if (input && input.options) {
if (input.options.selection || input.options.viewState || input.options.forceOpen || input.options.revealIfVisible || input.options.preserveFocus || input.options.pinned || input.options.inactive || typeof input.options.index === 'number') { if (input.options.selection || input.options.viewState || input.options.forceOpen || input.options.revealIfVisible || input.options.revealIfOpened || input.options.preserveFocus || input.options.pinned || input.options.inactive || typeof input.options.index === 'number') {
options = new TextEditorOptions(); options = new TextEditorOptions();
} }
...@@ -603,6 +610,10 @@ export class TextEditorOptions extends EditorOptions { ...@@ -603,6 +610,10 @@ export class TextEditorOptions extends EditorOptions {
options.revealIfVisible = true; options.revealIfVisible = true;
} }
if (input.options.revealIfOpened) {
options.revealIfOpened = true;
}
if (input.options.preserveFocus) { if (input.options.preserveFocus) {
options.preserveFocus = true; options.preserveFocus = true;
} }
...@@ -639,6 +650,7 @@ export class TextEditorOptions extends EditorOptions { ...@@ -639,6 +650,7 @@ export class TextEditorOptions extends EditorOptions {
options.preserveFocus = settings.preserveFocus; options.preserveFocus = settings.preserveFocus;
options.forceOpen = settings.forceOpen; options.forceOpen = settings.forceOpen;
options.revealIfVisible = settings.revealIfVisible; options.revealIfVisible = settings.revealIfVisible;
options.revealIfOpened = settings.revealIfOpened;
options.pinned = settings.pinned; options.pinned = settings.pinned;
options.index = settings.index; options.index = settings.index;
options.inactive = settings.inactive; options.inactive = settings.inactive;
...@@ -783,6 +795,7 @@ export class TextDiffEditorOptions extends TextEditorOptions { ...@@ -783,6 +795,7 @@ export class TextDiffEditorOptions extends TextEditorOptions {
options.preserveFocus = settings.preserveFocus; options.preserveFocus = settings.preserveFocus;
options.forceOpen = settings.forceOpen; options.forceOpen = settings.forceOpen;
options.revealIfVisible = settings.revealIfVisible; options.revealIfVisible = settings.revealIfVisible;
options.revealIfOpened = settings.revealIfOpened;
options.pinned = settings.pinned; options.pinned = settings.pinned;
options.index = settings.index; options.index = settings.index;
......
...@@ -248,17 +248,67 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic ...@@ -248,17 +248,67 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
} }
} }
public forward(): void { public forward(acrossEditors?: boolean): void {
if (this.stack.length > this.index + 1) { if (this.stack.length > this.index + 1) {
this.index++; if (acrossEditors) {
this.navigate(); this.doForwardAcrossEditors();
} else {
this.doForwardInEditors();
}
}
}
private doForwardInEditors(): void {
this.index++;
this.navigate();
}
private doForwardAcrossEditors(): void {
let currentIndex = this.index;
const currentEntry = this.stack[this.index];
// Find the next entry that does not match our current entry
while (this.stack.length > currentIndex + 1) {
currentIndex++;
const previousEntry = this.stack[currentIndex];
if (!this.matches(currentEntry.input, previousEntry.input)) {
this.index = currentIndex;
this.navigate(true /* across editors */);
break;
}
} }
} }
public back(): void { public back(acrossEditors?: boolean): void {
if (this.index > 0) { if (this.index > 0) {
this.index--; if (acrossEditors) {
this.navigate(); this.doBackAcrossEditors();
} else {
this.doBackInEditors();
}
}
}
private doBackInEditors(): void {
this.index--;
this.navigate();
}
private doBackAcrossEditors(): void {
let currentIndex = this.index;
const currentEntry = this.stack[this.index];
// Find the next previous entry that does not match our current entry
while (currentIndex > 0) {
currentIndex--;
const previousEntry = this.stack[currentIndex];
if (!this.matches(currentEntry.input, previousEntry.input)) {
this.index = currentIndex;
this.navigate(true /* across editors */);
break;
}
} }
} }
...@@ -271,14 +321,14 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic ...@@ -271,14 +321,14 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
this.recentlyClosedFiles = []; this.recentlyClosedFiles = [];
} }
private navigate(): void { private navigate(acrossEditors?: boolean): void {
const entry = this.stack[this.index]; const entry = this.stack[this.index];
let options = entry.options; let options = entry.options;
if (options) { if (options && !acrossEditors /* ignore line/col options when going across editors */) {
options.revealIfVisible = true; options.revealIfOpened = true;
} else { } else {
options = { revealIfVisible: true }; options = { revealIfOpened: true };
} }
this.navigatingInStack = true; this.navigatingInStack = true;
......
...@@ -25,13 +25,19 @@ export interface IHistoryService { ...@@ -25,13 +25,19 @@ export interface IHistoryService {
/** /**
* Navigate forwards in history. * Navigate forwards in history.
*
* @param acrossEditors instructs the history to skip navigation entries that
* are only within the same document.
*/ */
forward(): void; forward(acrossEditors?: boolean): void;
/** /**
* Navigate backwards in history. * Navigate backwards in history.
*
* @param acrossEditors instructs the history to skip navigation entries that
* are only within the same document.
*/ */
back(): void; back(acrossEditors?: boolean): void;
/** /**
* Removes an entry from history. * Removes an entry from history.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册