introduce forceActive flag as option for opening editors (fixes #182)

This commit is contained in:
Benjamin Pasero 2015-11-19 10:33:42 +01:00
parent c703e36c0b
commit 6a43144013
4 changed files with 20 additions and 2 deletions

View file

@ -72,6 +72,12 @@ export interface ITextInput {
* Will open the editor but not move keyboard focus into the editor. * Will open the editor but not move keyboard focus into the editor.
*/ */
preserveFocus?: boolean; preserveFocus?: boolean;
/**
* Ensures that the editor is being activated even if the input is already showing. This only applies
* if there is more than one editor open already and preserveFocus is set to false.
*/
forceActive?: boolean;
}; };
} }

View file

@ -652,6 +652,11 @@ export class EditorPart extends Part implements IEditorPart {
editor.focus(); editor.focus();
} }
// Otherwise check if we want to activate
else if (options && options.forceActive) {
this.sideBySideControl.setActive(editor);
}
// Progress Done // Progress Done
this.sideBySideControl.getProgressBar(position).done().getContainer().hide(); this.sideBySideControl.getProgressBar(position).done().getContainer().hide();

View file

@ -213,6 +213,12 @@ export class EditorOptions implements IEditorOptions {
*/ */
public forceOpen: boolean; public forceOpen: boolean;
/**
* Ensures that the editor is being activated even if the input is already showing. This only applies
* if there is more than one editor open already and preserveFocus is set to false.
*/
public forceActive: boolean;
/** /**
* Returns true if this options is identical to the otherOptions. * Returns true if this options is identical to the otherOptions.
*/ */
@ -258,9 +264,10 @@ export class TextEditorOptions extends EditorOptions {
/** /**
* Helper to create TextEditorOptions inline. * Helper to create TextEditorOptions inline.
*/ */
public static create(settings: { preserveFocus?: boolean; forceOpen?: boolean; selection?: IRange }): TextEditorOptions { public static create(settings: { preserveFocus?: boolean; forceOpen?: boolean; forceActive?: boolean; selection?: IRange }): TextEditorOptions {
let options = new TextEditorOptions(); let options = new TextEditorOptions();
options.preserveFocus = settings.preserveFocus; options.preserveFocus = settings.preserveFocus;
options.forceActive = settings.forceActive;
options.forceOpen = settings.forceOpen; options.forceOpen = settings.forceOpen;
if (settings.selection) { if (settings.selection) {

View file

@ -663,7 +663,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
if (control) { if (control) {
control.revealLineInCenterIfOutsideViewport(lineNumber); control.revealLineInCenterIfOutsideViewport(lineNumber);
control.setSelection({ startLineNumber: lineNumber, startColumn: 1, endLineNumber: lineNumber, endColumn: 1 }); control.setSelection({ startLineNumber: lineNumber, startColumn: 1, endLineNumber: lineNumber, endColumn: 1 });
return this.editorService.openEditor(visibleEditors[i].input, wbeditorcommon.TextEditorOptions.create({ preserveFocus: preserveFocus }), visibleEditors[i].position); return this.editorService.openEditor(visibleEditors[i].input, wbeditorcommon.TextEditorOptions.create({ preserveFocus: preserveFocus, forceActive: true }), visibleEditors[i].position);
} }
return Promise.as(null); return Promise.as(null);