@@ -2,7 +2,6 @@ use crate::parse::*;
2
2
use crate :: { Assoc , ChangeSet , Range , Rope , Selection , Transaction } ;
3
3
use once_cell:: sync:: Lazy ;
4
4
use regex:: Regex ;
5
- use std:: fs:: File ;
6
5
use std:: io:: { Read , Write } ;
7
6
use std:: num:: NonZeroUsize ;
8
7
use std:: time:: { Duration , Instant } ;
@@ -68,25 +67,23 @@ struct Revision {
68
67
timestamp : Instant ,
69
68
}
70
69
71
- const HEADER_TAG : & str = "Helix Undofile" ;
72
- const CURRENT_VERSION : u8 = 1 ;
70
+ const HEADER_TAG : & str = "Helix Undofile 0.1\n " ;
73
71
74
72
pub fn serialize_history < W : Write > ( writer : & mut W , history : & History ) -> std:: io:: Result < ( ) > {
75
73
write_string ( writer, HEADER_TAG ) ?;
76
- write_byte ( writer, CURRENT_VERSION ) ?;
77
74
write_usize ( writer, history. current ) ?;
78
75
write_vec ( writer, & history. revisions , serialize_revision) ?;
79
76
Ok ( ( ) )
80
77
}
81
78
82
79
pub fn deserialize_history < R : Read > ( reader : & mut R ) -> std:: io:: Result < History > {
83
- if HEADER_TAG != read_string ( reader) ? {
80
+ let header = read_string ( reader) ?;
81
+ if HEADER_TAG != header {
84
82
Err ( std:: io:: Error :: new (
85
83
std:: io:: ErrorKind :: Other ,
86
- "missing undofile header" ,
84
+ format ! ( "missing undofile header" ) ,
87
85
) )
88
86
} else {
89
- let _version = read_byte ( reader) ?;
90
87
let timestamp = Instant :: now ( ) ;
91
88
let current = read_usize ( reader) ?;
92
89
let revisions = read_vec ( reader, |reader| deserialize_revision ( reader, timestamp) ) ?;
0 commit comments