Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(layout/#592): layout tabs - part 3 - single tab mode #2032

Merged
merged 3 commits into from
Jun 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Feature/Layout/Configuration.re
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ let layoutTabPosition =
Codec.layoutTabPosition,
~default=`bottom,
);

let singleTabMode = setting("oni.layout.singleTabMode", bool, ~default=false);
13 changes: 12 additions & 1 deletion src/Feature/Layout/Feature_Layout.re
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ open Oni_Core.Utility;

include Model;

let openEditor = (~config, editor) =>
if (Local.Configuration.singleTabMode.get(config)) {
updateActiveGroup(Group.replaceAllWith(editor));
} else {
updateActiveGroup(Group.openEditor(editor));
};

// UPDATE

open Msg;
Expand Down Expand Up @@ -744,5 +751,9 @@ module Contributions = {
];

let configuration =
Configuration.[showLayoutTabs.spec, layoutTabPosition.spec];
Configuration.[
showLayoutTabs.spec,
layoutTabPosition.spec,
singleTabMode.spec,
];
};
2 changes: 1 addition & 1 deletion src/Feature/Layout/Feature_Layout.rei
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let split: ([ | `Horizontal | `Vertical], model) => model;

let activeEditor: model => Editor.t;

let openEditor: (Editor.t, model) => model;
let openEditor: (~config: Config.resolver, Editor.t, model) => model;
let closeBuffer: (~force: bool, Vim.Types.buffer, model) => option(model);

let addLayoutTab: model => model;
Expand Down
12 changes: 10 additions & 2 deletions src/Feature/Layout/Model.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module Local = {
module Configuration = Configuration;
};
open Oni_Core;
open Utility;
open Feature_Editor;
Expand All @@ -18,6 +21,7 @@ module Group: {
let nextEditor: t => t;
let previousEditor: t => t;
let openEditor: (Editor.t, t) => t;
let replaceAllWith: (Editor.t, t) => t;
let removeEditor: (int, t) => option(t);

let map: (Editor.t => Editor.t, t) => t;
Expand Down Expand Up @@ -92,6 +96,12 @@ module Group: {
};
};

let replaceAllWith = (editor, group) => {
...group,
editors: [editor],
selectedId: Editor.getId(editor),
};

let removeEditor = (editorId, group) => {
switch (List.filter(e => Editor.getId(e) != editorId, group.editors)) {
| [] => None
Expand Down Expand Up @@ -253,8 +263,6 @@ let nextEditor = updateActiveGroup(Group.nextEditor);

let previousEditor = updateActiveGroup(Group.previousEditor);

let openEditor = editor => updateActiveGroup(Group.openEditor(editor));

let removeLayoutTab = (index, model) => {
let left = Base.List.take(model.layouts, index);
let right = Base.List.drop(model.layouts, index + 1);
Expand Down
6 changes: 5 additions & 1 deletion src/Feature/Layout/View.re
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ module EditorGroupView = {
let make =
(
~provider as module ContentModel: ContentModel,
~config,
~showTabs,
~uiFont,
~theme,
Expand All @@ -280,7 +281,7 @@ module EditorGroupView = {
| None => React.empty
};

if (showTabs) {
if (showTabs && !Local.Configuration.singleTabMode.get(config)) {
let editors = model.editors |> List.rev;
let tabs =
<Tabs
Expand Down Expand Up @@ -456,6 +457,7 @@ module Layout = {
(
~provider,
~model as layout,
~config,
~isZenMode,
~showTabs,
~uiFont,
Expand Down Expand Up @@ -489,6 +491,7 @@ module Layout = {
<EditorGroupView
provider
uiFont
config
showTabs
isActive={group.id == layout.activeGroupId}
theme
Expand Down Expand Up @@ -548,6 +551,7 @@ let make =
<Layout
provider
model={activeLayout(model)}
config
isZenMode
showTabs
uiFont
Expand Down
1 change: 1 addition & 0 deletions src/Store/Features.re
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ let update =
...state,
layout:
Feature_Layout.openEditor(
~config=Feature_Configuration.resolver(state.config),
Feature_Editor.Editor.create(
~font=state.editorFont,
~buffer=editorBuffer,
Expand Down