mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
fix #19287
This commit is contained in:
parent
ec2ffab55f
commit
7239bb2c33
|
@ -281,24 +281,8 @@ export class TextDiffEditor extends BaseTextEditor {
|
|||
public getSecondaryActions(): IAction[] {
|
||||
const actions = super.getSecondaryActions();
|
||||
|
||||
const control = this.getControl();
|
||||
|
||||
let inlineModeActive = control && !control.renderSideBySide;
|
||||
const inlineLabel = nls.localize('inlineDiffLabel', "Switch to Inline View");
|
||||
const sideBySideLabel = nls.localize('sideBySideDiffLabel', "Switch to Side by Side View");
|
||||
|
||||
// Action to toggle editor mode from inline to side by side
|
||||
const toggleEditorModeAction = new Action('toggle.diff.editorMode', inlineModeActive ? sideBySideLabel : inlineLabel, null, true, () => {
|
||||
this.getControl().updateOptions(<IDiffEditorOptions>{
|
||||
renderSideBySide: inlineModeActive
|
||||
});
|
||||
|
||||
inlineModeActive = !inlineModeActive;
|
||||
toggleEditorModeAction.label = inlineModeActive ? sideBySideLabel : inlineLabel;
|
||||
|
||||
return TPromise.as(true);
|
||||
});
|
||||
|
||||
const toggleEditorModeAction = new ToggleEditorModeAction(this);
|
||||
toggleEditorModeAction.order = 50; // Closer to the end
|
||||
|
||||
actions.push(...[
|
||||
|
@ -354,4 +338,35 @@ class NavigateAction extends Action {
|
|||
public updateEnablement(): void {
|
||||
this.enabled = this.editor.getDiffNavigator().canNavigate();
|
||||
}
|
||||
}
|
||||
|
||||
class ToggleEditorModeAction extends Action {
|
||||
private static ID = 'toggle.diff.editorMode';
|
||||
private static INLINE_LABEL = nls.localize('inlineDiffLabel', "Switch to Inline View");
|
||||
private static SIDEBYSIDE_LABEL = nls.localize('sideBySideDiffLabel', "Switch to Side by Side View");
|
||||
|
||||
constructor(private editor: TextDiffEditor) {
|
||||
super(ToggleEditorModeAction.ID);
|
||||
}
|
||||
|
||||
public get label(): string {
|
||||
return ToggleEditorModeAction.isInlineMode(this.editor) ? ToggleEditorModeAction.SIDEBYSIDE_LABEL : ToggleEditorModeAction.INLINE_LABEL;
|
||||
}
|
||||
|
||||
public run(): TPromise<any> {
|
||||
const inlineModeActive = ToggleEditorModeAction.isInlineMode(this.editor);
|
||||
|
||||
const control = this.editor.getControl();
|
||||
control.updateOptions(<IDiffEditorOptions>{
|
||||
renderSideBySide: inlineModeActive
|
||||
});
|
||||
|
||||
return TPromise.as(true);
|
||||
}
|
||||
|
||||
private static isInlineMode(editor: TextDiffEditor): boolean {
|
||||
const control = editor.getControl();
|
||||
|
||||
return control && !control.renderSideBySide;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue