Write path fixes#2267
Conversation
|
Not really sure what's going on with the EAGAIN errors. Trying to dig into it. I'm guessing it has something to do with the terminal in the build environment. |
|
Would it be possible to split the PR up into two - one for the integration tests and one to fix document writes (probably based on the integration testing one)? It is quite large as you say 😅 |
|
Sure, I have some of the changes mixed up, but I'll see if I can rebase and split them up |
4590de4 to
1bfb5a8
Compare
|
I think you accidentally included |
Thanks! I fixed this. Though as a side note, if you'd like to review, I'd recommend taking a look at #2359 first, as this PR is based on that one. A review would be appreciated. 🙂 |
| pub fn is_single_grapheme(&self, doc: RopeSlice) -> bool { | ||
| let mut graphemes = RopeGraphemes::new(doc.slice(self.from()..self.to())); |
There was a problem hiding this comment.
We usually call it text instead of doc.
| debug!( | ||
| "document {:?} saved with revision {}", | ||
| doc.path(), | ||
| doc_save_event.revision | ||
| ); |
There was a problem hiding this comment.
Hmm, I wonder why editors don't show user the revision, if it did then users are able to use time travel easily. Like :ear 1f, but yeah the issue could be that even if we show it, user don't know the range they could use for time travel, like 1 or 0 is the min but don't know the max if they travel back.
38d3da0 to
d7899e9
Compare
3b0e987 to
dae8cb8
Compare
|
Can you rebase this now? :) |
|
Yep, will do next time I get a chance. Although I meant to make a comment here: I've been dogfooding this branch for a little while, and I've noticed one issue with the changes to the revision number tracking: when an auto format happens, helix doesn't mark it as unmodified because the revision number it saves for sending across the channel happens before the formatting change, which itself increases the revision number. I will have to think about how to fix this. I may have to split up the format and save operations into discrete steps so it can do the formatting first and then save the revision number before issuing the write operation. |
To reduce likelihood of accidental discarding of important callbacks
5c65ff7 to
756253b
Compare
archseer
left a comment
There was a problem hiding this comment.
It's time! I want to refactor things further to get rid of the Callback enum, but we should ship these write fixes first
|
I am not able to write to a file by helix but I am able to do with vim, what is the reason ? |
|
nevermind, it got automaticaly fixed |
Edit: this PR was split up, now integration tests are in #2359 and this PR is based on that branch.
Well, I did not expect this PR to get this large, I'm so sorry about that. This PR started as an attempt to fix #1575, and along the way, I discovered that there was a larger problem: Document writes are submitted to a single job pool that all run unordered. I suspected that this could lead to file write inconsistencies if the user submitted multiple writes on the same document at the same time. I took this opportunity to continue work on the integration testing harness that @archseer started a while back. I added an integration test (see below) that confirms that indeed the file writes happen not only out of order, but simtultaneously, leading to the file being clobbered. In a test where we issue a thousand writes that each change the entire file to consist only of the iteration number (i.e., 1, 2, 3, ..., 1000), we can see that the file ends up with a seemingly random jumble:
This test is now passing with the changes to the write path.
Below is an explanation of some of my decisions in this PR. Opinions and suggestions are welcome!
Document writes
The approach taken was:
Incidentally, this allowed fixes for two unrelated bugs that presently exist:
Also, the first attempt at fixing #1575 was done by adding fallibility to the job pool. Presently, if you join on all the jobs, any errors are discarded.
Since I was already here, I attempted to fix #1633 as well, and it kind of works, except that the status message quickly gets overwritten by LSP progress messages. I'm not quite sure how to fix this, but I think that can happen in another PR, as this one is quite big enough already.
Edit: integration tests were split off into their own PR: #2359
Fixes #3975
Fixes #2518
Fixes #3727