Commit Graph

52 Commits (dfc17becd56efbc1f65de7c8d65cb32ad4690db1)

Author SHA1 Message Date
Blaž Hrastnik 1d96cbfbd2 Transaction: Add a changes_iter() that can convert back to a list of Changes 4 years ago
Blaž Hrastnik a74ff6bc03 Transaction: need to consume insert | delete properly. 4 years ago
Blaž Hrastnik 06aca7691c clippy lint 4 years ago
Blaž Hrastnik cbcacb1063 Merge some imports. 4 years ago
Blaž Hrastnik 798dbd27c5 Selection: fail early if new() is called with no ranges. 4 years ago
Blaž Hrastnik f29f01858d Implement iter() and len() directly on Selection. 4 years ago
Blaž Hrastnik 59e6024186 Remove State from a few more signatures. 4 years ago
Blaž Hrastnik 8eaf9a432d Make Transaction::change only rely on the rope. 4 years ago
Blaž Hrastnik 1cf887dea9 Cleanup: use doc.selection() instead of doc.state.selection(). 4 years ago
Blaž Hrastnik af55ebd002 transaction: Also modify map_pos to work with insert|delete order. 4 years ago
Blaž Hrastnik 9cac44c7c0 minor changes 4 years ago
Blaž Hrastnik 9821c4dd3b Optimize Changeset::is_empty()
Checked the ASM output for these three options:

pub enum Operation {
    /// Move cursor by n characters.
    Retain(usize),
    /// Delete n characters.
    Delete(usize),
    /// Insert text at position.
    Insert(String),
}

pub struct A {
    changes: Vec<Operation>,
    len: usize,
}

impl A {
    pub fn is_empty1(&self) -> bool {
        match self.changes.as_slice() {
            [] => true,
            [Operation::Retain(_)] => true,
            _ => false,
        }
    }

    /// `true` when the set is empty.
    pub fn is_empty2(&self) -> bool {
        let len = self.changes.len();
        len == 0
        || (
            len == 1
            && self.changes[0] == Operation::Retain(self.len)
        )

    }

    pub fn is_empty3(&self) -> bool {
        match self.changes.as_slice() {
            [] | [Operation::Retain(_)] => true,
            _ => false
        }
    }

}
4 years ago
Blaž Hrastnik b0b5451c38 Since insert preceedes deletes, follow that ordering in Transaction::changes.
Produces the same output but will take the happy path.
4 years ago
Blaž Hrastnik b4312c9492 transaction: Use builder methods to generate compact changesets. 4 years ago
Blaž Hrastnik 19fb4ed835 transaction: Merge consecutive inserts on compose. 4 years ago
Blaž Hrastnik 777a80917d Address clippy lints. 4 years ago
Blaž Hrastnik cc6bdf8f66 Text change generation, RPC call handling. 4 years ago
Blaž Hrastnik b39849dde1 Refactor: Document type as a wrapper around barebones State. 4 years ago
Blaž Hrastnik 0b74d423d0 Validate compose len after applying a is same as before applying b. 4 years ago
Blaž Hrastnik 7fcc6f8f1b Fix overlapping (insert | delete) compose 4 years ago
Blaž Hrastnik 94f9603c74 Fix compose not merging certain changesets correctly. 4 years ago
Blaž Hrastnik 4a648555ed Don't try to compose zero-width deletes. 4 years ago
Blaž Hrastnik 490e23b645 Simplify changeset tracking. 4 years ago
Blaž Hrastnik 8098279676 Cleanup 4 years ago
Blaž Hrastnik 1dba0f2b1c Simple yank/paste registers. 4 years ago
Blaž Hrastnik eba5b1ef33 Fix changeset composition, lengths don't have to match. 4 years ago
Blaž Hrastnik b765c17896 Hacky undo/redo integration. 4 years ago
Blaž Hrastnik fd311fb8ad Undo tree draft.
We keep a tree of transactions. This allows for persistent undo by
simply serializing the changesets.
4 years ago
Blaž Hrastnik 883b77bd24 Fix transaction.invert()/.apply() using byte counts instead of char counts. 4 years ago
Blaž Hrastnik aa077a07f3 Implement Transaction::invert. 4 years ago
Blaž Hrastnik 36e7e2133f Split selection on regex, fix InputEdit generation. 4 years ago
Blaž Hrastnik 3020077da8 Extend selection commands. 4 years ago
Blaž Hrastnik 48330ddb5f Command needs access to view information for certain changes. 4 years ago
Blaž Hrastnik 3859f6963d More work on the UI. 4 years ago
Blaž Hrastnik 088f8a82af Incremental parsing: rough draft. 4 years ago
Blaž Hrastnik 96db02742e Simplify some more code. 4 years ago
Blaž Hrastnik 0427acd18c Avoid collect() by accepting iterators into Transaction::change. 4 years ago
Blaž Hrastnik b08278807e Add 'A', 'I' commands. 4 years ago
Blaž Hrastnik fb0f56b747 Add 'o' command. 4 years ago
Blaž Hrastnik 22cb7b3338 Change -> Operation, Change2 -> Change 4 years ago
Blaž Hrastnik d86f0feafc Abstract Transaction::change from change_by_selection. 4 years ago
Blaž Hrastnik d466882d04 Abstract Transaction::change_by_selection, working del/backspace. 4 years ago
Blaž Hrastnik dd749bb284 Expand transaction API. 4 years ago
Blaž Hrastnik 8b3e152126 cleanup: Make Buffer just a part of State. 4 years ago
Blaž Hrastnik 579b6899f1 Work on insert mode. 4 years ago
Blaž Hrastnik 387fb57c94 Allow unused code for the time being. 5 years ago
Blaž Hrastnik 6905ff03c2 Start swapping from termwiz to crossterm + async. 5 years ago
Blaž Hrastnik 1984410ac9 Selection mapping over changesets. 5 years ago
Blaž Hrastnik e52e848fd7 changeset: Introduce map_pos. 5 years ago
Blaž Hrastnik b5c38812e9 address clippy warnings 5 years ago