Skip to content

Commit

Permalink
Add activeEditorShort and activeFolderShort
Browse files Browse the repository at this point in the history
  • Loading branch information
shulhi committed Dec 4, 2019
1 parent 4faf893 commit 0270b50
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/Store/TitleStoreConnector.re
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ module Model = Oni_Model;

module Actions = Model.Actions;

let getDirectory = (fp: string): option(string) => {
let dirs =
Filename.dirname(fp) |> String.split_on_char(Filename.dir_sep.[0]);

List.length(dirs) - 1 |> List.nth_opt(dirs);
};

let start = setTitle => {
let _lastTitle = ref("");

Expand All @@ -26,8 +33,20 @@ let start = setTitle => {
| None => initialValues
| Some(fp) =>
let activeEditorShort = Filename.basename(fp);
[("activeEditorShort", activeEditorShort), ...initialValues];
let parentDir = getDirectory(fp);

let initialValues = [
("activeEditorShort", activeEditorShort),
("activeEditorLong", fp),
...initialValues,
];

switch (parentDir) {
| None => initialValues
| Some(dir) => [("activeFolderShort", dir), ...initialValues]
};
};

switch (Model.Buffer.isModified(buf)) {
| false => ret
| true => [("dirty", "*"), ...ret]
Expand All @@ -39,6 +58,7 @@ let start = setTitle => {
| None => initialValues
| Some(workspace) => [
("rootName", workspace.rootName),
("rootPath", workspace.workingDirectory),
...initialValues,
]
};
Expand Down Expand Up @@ -72,4 +92,4 @@ let start = setTitle => {
};
};
updater;
};
};

0 comments on commit 0270b50

Please sign in to comment.