-
Notifications
You must be signed in to change notification settings - Fork 103
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Persistent modes #281
Open
jmacdonald
wants to merge
36
commits into
main
Choose a base branch
from
persistent-modes
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Persistent modes #281
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jmacdonald
force-pushed
the
persistent-modes
branch
from
April 7, 2024 03:20
1bb8ceb
to
c85fb56
Compare
These should be mutated through switch_to.
jmacdonald
force-pushed
the
persistent-modes
branch
3 times, most recently
from
April 8, 2024 03:06
f63d8cf
to
48bab5e
Compare
This one is a big win, as jump mode effectively implemented persistent select modes all on its own, which is now solved by the app-wide persistent modes.
jmacdonald
force-pushed
the
persistent-modes
branch
from
April 8, 2024 03:45
48bab5e
to
2335e6b
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As of today, Amp tracks its current/active mode using a single
enum
field on theApplication
type. When the active mode is changed, the old mode is discarded and a new one is constructed. A side effect of this is that the active mode's state is lost during the transition. There are situations where persisting and recalling state across modes is beneficial:Select
/SelectLine
modes, temporarily switching to jump mode to select the end of the rangeThe first two behaviors above exist today, but as you'll see in the diff below, they're implemented by explicitly storing required state in their relevant modes or the
Application
type itself. This has helped minimize and isolate the complexity involved with persistent state, but as we look to implement more features that require it, the pattern justifies building a generalized system that handles this for all use cases.That generalized system is the focus of this PR. As you'll see below, we now build all application modes up front, store them in a hash map, and recall them when switching modes. To do so, I needed to introduce the following notable changes:
Application
type to hydrate the mapModeKey
type as a statelessenum
key into the mapreset
method to modes where a clean slate is expected (e.g. rebuilding open mode's project directory index)Once this lands, we'll be able to leverage these persistent modes to build some neat features that should really help improve the ergonomics of Amp. 馃槑