Skip to content

Commit

Permalink
feat(workspace/#640): persistence infrastructure + persist workspace …
Browse files Browse the repository at this point in the history
…and window state (#1703)

* add Filesystem.getStoreFolder

* expose Filesystem.getOrCreateConfigFolder

* add definition of Persistence "items"

* add definitions for Global store

* add store instantiation

* add logic to write to file

* trigger on state change

* add Workspace store

* persist workspace store on move and resize

* remove cliOptions from StoreThread in favor of explicit arguments

* move Cli from Core to bin_editor

* fall back to persisted working directory if not specified on the command line

* read store file on instantiation

* add get function to retrieve an item from the store

* make state.workspace non-optional

* set window size and position initially based on persisted workspace settings

* post-rebase fix

* fix warning

* add interface

* refactor

* special case hash for "global"

* fix window positioning

* add bool codec

* persist maximized window state

* cache store file path

* use Luv for non-blocking I/O on persist

* fall back to Documents instead of working directory

* move Persistence infrastructure to Core

* forward store infrastructure functions to builtin stores

* refactor store API for great good

* simplify builtin store API

* fix tests

* handle missing store path more gracefully

* Switch to new Dir API

* Use forked dir for now

* Update lockfiles

* Formatting

Co-authored-by: bryphe <bryphe@outrunlabs.com>
  • Loading branch information
glennsl and bryphe authored May 5, 2020
1 parent 5c7d197 commit 9aac90b
Show file tree
Hide file tree
Showing 37 changed files with 1,412 additions and 1,064 deletions.
419 changes: 205 additions & 214 deletions bench.esy.lock/index.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bench.esy.lock/opam/conf-pkg-config.1.1/opam

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bench/lib/Helpers.re
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let simpleState = {
State.initial(
~getUserSettings=() => Ok(Config.Settings.empty),
~contributedCommands=[],
~workingDirectory=Sys.getcwd(),
);

Reducer.reduce(
Expand Down
419 changes: 205 additions & 214 deletions esy.lock/index.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion esy.lock/opam/conf-pkg-config.1.1/opam

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 1 addition & 10 deletions integration_test/ZenModeSingleFileModeTest.re
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
open Oni_Core;
open Oni_Model;
open Oni_IntegrationTestLib;

Expand All @@ -8,17 +7,9 @@ let configuration = {|
{ "editor.zenMode.singleFile": true }
|};

let cliOptions =
Cli.create(
~folder=Revery.Environment.getWorkingDirectory(),
// Specify a single file
~filesToOpen=["some-random-file.txt"],
(),
);

runTest(
~configuration=Some(configuration),
~cliOptions=Some(cliOptions),
~filesToOpen=["some-random-file.txt"],
~name="ZenMode: Single-file mode works as expected",
(_dispatch, wait, _runEffects) => {
wait(~name="Wait for split to be created 1", (state: State.t) => {
Expand Down
12 changes: 9 additions & 3 deletions integration_test/lib/Oni_IntegrationTestLib.re
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ let runTest =
(
~configuration=None,
~keybindings=None,
~cliOptions=None,
~filesToOpen=[],
~name="AnonymousTest",
~onAfterDispatch=_ => (),
test: testCallback,
Expand Down Expand Up @@ -94,7 +94,13 @@ let runTest =
let getUserSettings = () => Ok(currentUserSettings^);

let currentState =
ref(Model.State.initial(~getUserSettings, ~contributedCommands=[]));
ref(
Model.State.initial(
~getUserSettings,
~contributedCommands=[],
~workingDirectory=Sys.getcwd(),
),
);

let headlessWindow =
Revery.Utility.HeadlessWindow.create(
Expand Down Expand Up @@ -147,11 +153,11 @@ let runTest =
~executingDirectory=Revery.Environment.getExecutingDirectory(),
~getState=() => currentState^,
~onStateChanged,
~cliOptions,
~configurationFilePath=Some(configurationFilePath),
~keybindingsFilePath=Some(keybindingsFilePath),
~quit,
~window=None,
~filesToOpen,
(),
);

Expand Down
2 changes: 1 addition & 1 deletion integration_test/lib/Oni_IntegrationTestLib.rei
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let runTest:
(
~configuration: option(string)=?,
~keybindings: option(string)=?,
~cliOptions: option(Core.Cli.t)=?,
~filesToOpen: list(string)=?,
~name: string=?,
~onAfterDispatch: Model.Actions.t => unit=?,
testCallback
Expand Down
Loading

0 comments on commit 9aac90b

Please sign in to comment.