-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Persistent Undo #5608
Persistent Undo #5608
Conversation
af7092c
to
47a3ea2
Compare
This comment was marked as outdated.
This comment was marked as outdated.
012afed
to
d3b9d9c
Compare
This comment was marked as outdated.
This comment was marked as outdated.
9ce94fc
to
fd0f0b1
Compare
de665c4
to
587ad62
Compare
That's not quite what I meant. What I meant instead is that there is some central location (notably not a session but rather somewhere central. For example nvim default to Ofcourse you can not joint the absolute paths on top of a directory. However you can escape a path. I am also of the opinion that the undofile should be (if enabled) automatically written on save and automatically opened when a file is opened instead of manually opened from a session. In general undofiles are seperate from sessions to me. Just like in nvim undofiles should be seperate because they are decidedly not session specific. Each file has one history of changes no matter what session performs these changes (which is why I think it's better to autoamtically save and load undofiles from a centralized location instead of manual load from a specific session). With such a global approach the indexfile becomes impractical. There would be laods of conflict and dataloss for that index file between different helix instances whereas for standalone escaped undofiles only have contention when two helix instances write to the same file (in which case there is already contention anyway which is a seperate problem to solve with file watching/mtime safeguard) |
Yeah, that seems like an overall improvement and not too big of a change. One thing I liked about workspaces in VSCode (but forgot to implement here) is that it would open the last open buffers. Maybe something like that could be done by looking for undofiles beginning with the cwd path, and having |
I'm also for having undo-files separate from sessions since I plan to use sessions, but not undo-files. |
I think that is a session related feature. Like I said I think sessions and undofiles are separate features. So the undofiles always get opened and saved when the files do (if the setting is enabled). However open buffers only get restored when a session is opened (would just be a list of paths stored in the session file). These two files have seperate lifetimes and I think mixing them will only lead to problems. |
587ad62
to
71492ce
Compare
e9ff360
to
d650195
Compare
I've implemented reloading the history on |
Idk if I am missing something, I will assume no reply means I am not in the know. And I am not sure what was decided on loading the undo file into memory. But: I understand undos to work as operations pushed to a Vec. Regarding the same file being edited by different instances of helix, can't the timestamp of the most recent operation be saved also, and whichever list has the most recent timestamp be the one that is maintained? So if instance A of helix writes the file that is open and therefore writes to the undo list, when instance B goes to save it can see that it is not at the most recent version of the file and can open the most recent version as a swapfile to compare changes (which also loads the newest version of the undo list), or overwrites its version of the file with the most recent one, which also overwrites its version of the undo list that it has loaded into memory. I think I am largely reiterating PascalKuthe's comments. But I feel the tree is unnecessary: simply load the undo list into memory upon opening a file, overwrite the list on save. Again apologies if this is a timewasting comment, I am a noob desperate to learn. |
See #5608 (comment) The undo history is already a tree as well. |
02f4d8d
to
c6e50d2
Compare
c39d674
to
8a60b79
Compare
1b3a176
to
cf81ab7
Compare
The test for reloading don't seem sufficient, since I ran into a case where it panics. This was the revisions deserialized so far, and the revision that had an invalid parent: Revision {
parent: 1,
last_child: None,
transaction: Transaction {
changes: ChangeSet {
changes: [
Retain(
6998,
),
Delete(
2,
),
Retain(
23442,
),
],
len: 30442,
len_after: 30440,
},
selection: Some(
Selection {
ranges: [
Range {
anchor: 6998,
head: 6999,
old_visual_position: None,
},
],
primary_index: 0,
},
),
},
inversion: Transaction {
changes: ChangeSet {
changes: [
Retain(
6998,
),
Insert(
"md",
),
Retain(
23442,
),
],
len: 30440,
len_after: 30442,
},
selection: Some(
Selection {
ranges: [
Range {
anchor: 7000,
head: 7001,
old_visual_position: Some(
(
0,
13,
),
),
},
],
primary_index: 0,
},
),
},
timestamp: Instant {
tv_sec: 21118,
tv_nsec: 598440833,
},
},
] Revision {
parent: 2,
last_child: None,
transaction: Transaction {
changes: ChangeSet {
changes: [
Retain(
6998,
),
Insert(
"md",
),
Retain(
23442,
),
],
len: 30440,
len_after: 30442,
},
selection: Some(
Selection {
ranges: [
Range {
anchor: 7001,
head: 7000,
old_visual_position: None,
},
],
primary_index: 0,
},
),
},
inversion: Transaction {
changes: ChangeSet {
changes: [
Retain(
6998,
),
Delete(
2,
),
Retain(
23442,
),
],
len: 30442,
len_after: 30440,
},
selection: Some(
Selection {
ranges: [
Range {
anchor: 6999,
head: 6998,
old_visual_position: None,
},
],
primary_index: 0,
},
),
},
timestamp: Instant {
tv_sec: 21118,
tv_nsec: 598440833,
},
} I'm concerned about the apparently missing revisions, especially since all histories at least have an empty initial revision which should have been deserialized too. |
I think I traced the cause of the bug to how the history is saved in |
Thanks so much for your work on this @kirawi! |
Will be superseded by a new PR. |
is this issue fixed ? what is the conclusion ? |
I'd venture to guess: #9154 |
Objective
Implement persistent undo as part of #401
Solution
helix-core::parse
.History
. At the moment,timestamp
s aren't preserved.:reload
will also merge the saved history with the current one.persistent-undo
at runtime will cause the histories of open docs to be merged as well.Changelog
implemented persistent undo