File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,23 @@ mod lines {
5858
5959use lines:: LoadedLine ;
6060
61+ // TODO
62+ // How to represent edited content?
63+ //
64+ // Main problem: "insert char" pushes all remaining memory forward.
65+ //
66+ // Other editors:
67+ // - emacs: gap buffer
68+ // - vim: rope
69+ //
70+ // Idea:
71+ // List of contiguous chunks: (disk_offset, data, is_modified).
72+ // When a char is inserted in the middle of a chunk, split it into three: prev, cur, next.
73+ // prev and next remain unchanged (can be dropped from memory and reloaded from disk).
74+ // When saving the file, iterate chunks: write to disk, update disk_offset, set is_modified = false
75+ // if disk_offset = write offset and is_modified = false, no need to write (skip the chunk).
76+ // This can optimize writing huge files.
77+
6178struct State {
6279 /// Content loaded from the file, may be a small portion of the entire file starting at some offset
6380 lines : Vec < LoadedLine > ,
You can’t perform that action at this time.
0 commit comments