Commit Graph

63 Commits (dd2903ff10387c04e933aa37846663131297b8b3)

Author SHA1 Message Date
Nathan Vegdahl 220bc85821 Fix all remaining warnings in helix-core except for two.
I'm not sure how to address them, because they look like they
might be bugs, and code is involved.  Will poke the relevant people.
3 years ago
Nathan Vegdahl b571f28641 Remove #[allow(unused)] from helix-core, and fix unused imports.
Still a bunch more warnings to fix in core, but it's a start.
3 years ago
Blaž Hrastnik 51162ae6b2 fix ca98210d20 3 years ago
Blaž Hrastnik ca98210d20 fix: insert() | delete() would calculate the new insert incorrectly
Refs #386
3 years ago
Ivan Tham 7cc13fefe9 Derive debug without feature
Note that this also removed those `finish_non_exhaustive()`.
3 years ago
notoria 1a3a924634 Implement Debug for data structure as a feature 3 years ago
Kirawi b873fb9897
Fix Unicode (#135)
* init

* wip

* wip

* fix unicode break

* fix unicode break

* Update helix-core/src/transaction.rs

Co-authored-by: Benoît Cortier <benoit.cortier@fried-world.eu>

* clippy

* fix

* add changes

* added test

* wip

* wip

* wip

* wip

* fix

* fix view

* fix #88

Co-authored-by: Benoît Cortier <benoit.cortier@fried-world.eu>
3 years ago
Kirawi c17dcb8633
Fixing Multiple Panics (#121)
* init

* wip

* wip
3 years ago
Ivan Tham f5f46b1fed Separate document history into Cell
As history is used separately from the rest of the edits, separating it
can avoid needless borrowing and cloning. But one need to be aware later.
3 years ago
Blaž Hrastnik f00cb15137 core: Improve changeset composition behavior.
It would fail to combine with an empty set.
3 years ago
Blaž Hrastnik 9eaef6e333 Fully drop State references. 3 years ago
Blaž Hrastnik 1d96cbfbd2 Transaction: Add a changes_iter() that can convert back to a list of Changes 3 years ago
Blaž Hrastnik a74ff6bc03 Transaction: need to consume insert | delete properly. 3 years ago
Blaž Hrastnik 06aca7691c clippy lint 3 years ago
Blaž Hrastnik cbcacb1063 Merge some imports. 3 years ago
Blaž Hrastnik 798dbd27c5 Selection: fail early if new() is called with no ranges. 3 years ago
Blaž Hrastnik f29f01858d Implement iter() and len() directly on Selection. 3 years ago
Blaž Hrastnik 59e6024186 Remove State from a few more signatures. 3 years ago
Blaž Hrastnik 8eaf9a432d Make Transaction::change only rely on the rope. 3 years ago
Blaž Hrastnik 1cf887dea9 Cleanup: use doc.selection() instead of doc.state.selection(). 3 years ago
Blaž Hrastnik af55ebd002 transaction: Also modify map_pos to work with insert|delete order. 3 years ago
Blaž Hrastnik 9cac44c7c0 minor changes 3 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
        }
    }

}
3 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.
3 years ago
Blaž Hrastnik b4312c9492 transaction: Use builder methods to generate compact changesets. 3 years ago
Blaž Hrastnik 19fb4ed835 transaction: Merge consecutive inserts on compose. 3 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