Skip to content

Commit b6f6a73

Browse files
author
Noam Lewis
committed
Comments
1 parent 1b4df43 commit b6f6a73

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/main.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,23 @@ mod lines {
5858

5959
use 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+
6178
struct State {
6279
/// Content loaded from the file, may be a small portion of the entire file starting at some offset
6380
lines: Vec<LoadedLine>,

0 commit comments

Comments
 (0)