aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/transaction.rs
Commit message (Collapse)AuthorAge
* Reformat with nightly rustfmt for better let-else formatting (#7721)Philipp Mildenberger2023-07-27
|
* Prefer RopeSlice to &Rope in helix_core::syntaxMichael Davis2023-07-27
| | | | | | | | | | | | | | | Pascal and I discussed this and we think it's generally better to take a 'RopeSlice' rather than a '&Rope'. The code block rendering function in the markdown component module is a good example for how this can be useful: we can remove an allocation of a rope and instead directly turn a '&str' into a 'RopeSlice' which is very cheap. A change to prefer 'RopeSlice' to '&Rope' whenever the rope isn't modified would be nice, but it would be a very large diff (around 500+ 500-). Starting off with just the syntax functions seems like a nice middle-ground, and we can remove a Rope allocation because of it. Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
* correctly map unsorted positions (#7471)Pascal Kuthe2023-06-28
| | | | | | | | | | | * correctly map unsorted positions * Fix typo Co-authored-by: Michael Davis <mcarsondavis@gmail.com> --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* map positions through changes in O(N)Pascal Kuthe2023-06-25
|
* don't move cursor while forward deleting in append modePascal Kuthe2023-05-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, when forward deleting (`delete_char_forward` bound to `del`, `delete_word_forward`, `kill_to_line_end`) the cursor is moved to the left in append mode (or generally when the cursor is at the end of the selection). For example in a document `|abc|def` (|indicates selection) if enter append mode the cursor is moved to `c` and the selection becomes: `|abcd|ef`. When deleting forward (`del`) `d` is deleted. The expectation would be that the selection doesn't shrink so that `del` again deletes `e` and then `f`. This would look as follows: `|abcd|ef` `|abce|f` `|abcf|` `|abc |` This is inline with how other editors like kakoune work. However, helix currently moves the selection backwards leading to the following behavior: `|abcd|ef` `|abc|ef` `|ab|ef` `ef` This means that `delete_char_forward` essentially acts like `delete_char_backward` after deleting the first character in append mode. To fix the problem the cursor must be moved to the right while deleting forward (first fix in this commit). Furthermore, when the EOF char is reached a newline char must be inserted (just like when entering appendmode) to prevent the cursor from moving to the right
* fix panic when deleting overlapping rangesPascal Kuthe2023-05-18
| | | | | | | | | | | | | Some deletion operations (especially those that use indentation) can generate overlapping deletion ranges when using multiple cursors. To fix that problem a new `Transaction::delete` and `Transaction:delete_by_selection` function were added. These functions merge overlapping deletion ranges instead of generating an invalid transaction. This merging of changes is only possible for deletions and not for other changes and therefore require its own function. The function has been used in all commands that currently delete text by using `Transaction::change_by_selection`.
* Add API to create a Transaction from potentially overlapping changesPascal Kuthe2023-03-10
| | | | | | | | | | | | This commit adds new functions to `Transaction` that allow creating edits that might potentially overlap. Any change that overlaps previous changes is ignored. Furthermore, a utility method is added that also drops selections associated with dropped changes (for transactions that are created from a selection). This is needed to avoid crashes when applying multicursor autocompletions, as the edit from a previous cursor may overlap with the next cursor/edit.
* properly handle LSP position encoding (#5711)Pascal Kuthe2023-02-09
| | | | | | | | | | | | | * properly handle LSP position encoding * add debug assertion to Transaction::change * Apply suggestions from code review Co-authored-by: Michael Davis <mcarsondavis@gmail.com> --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* Significantly improve performance of `:reload` (#4457)Pascal Kuthe2022-11-28
| | | | | * bump ropey to 1.5.1-alpha * significantly improve performance of :reload
* fix testsBlaž Hrastnik2022-11-08
|
* fix testsBlaž Hrastnik2022-11-08
|
* core: transaction: Resolve some TODOsBlaž Hrastnik2022-03-03
|
* Replace tendril with smartstringBlaž Hrastnik2022-02-10
| | | | Slightly smaller API surface, less dependencies.
* Fix Clippy lints in tests (#1563)Omnikar2022-01-23
| | | Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* Add auto pairs for same-char pairs (#1219)Skyler Hawthorne2021-12-13
| | | | | | | | | | | | | | | * Add auto pairs for same-char pairs * Add unit tests for all existing functionality * Add auto pairs for same-char pairs (quotes, etc). Account for apostrophe in prose by requiring both sides of the cursor to be non-pair chars or whitespace. This also incidentally will work for avoiding a double single quote in lifetime annotations, at least until <> is added * Slight factor of moving the cursor transform of the selection to inside the hooks. This will enable doing auto pairing with selections, and fixing the bug where auto pairs destroy the selection. Fixes #1014
* Address new lint on 1.57Blaž Hrastnik2021-12-03
|
* fix: Correctly detect empty transactionsBlaž Hrastnik2021-12-02
| | | | Fixes #1221
* completion: fully revert state before apply & insertText common prefixBlaž Hrastnik2021-10-25
|
* fix: Compose where changes.compose(empty_other)Blaž Hrastnik2021-10-25
|
* remove unsafeBrian Shu2021-08-27
|
* Fix tests broken by the State changeBlaž Hrastnik2021-08-26
|
* Reduce State use a bit furtherBlaž Hrastnik2021-08-26
| | | | This is a legacy type that should be fully removed.
* Remove ExactSizeIterator requirement on Transaction::changeBlaž Hrastnik2021-07-19
| | | | Size hint is enough.
* Fix all remaining warnings in helix-core except for two.Nathan Vegdahl2021-07-02
| | | | | 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.
* Remove #[allow(unused)] from helix-core, and fix unused imports.Nathan Vegdahl2021-07-02
| | | | Still a bunch more warnings to fix in core, but it's a start.
* fix ca98210d2016d96d1c441932d7a67bbc6e5eccb7Blaž Hrastnik2021-06-28
|
* fix: insert() | delete() would calculate the new insert incorrectlyBlaž Hrastnik2021-06-28
| | | | Refs #386
* Derive debug without featureIvan Tham2021-06-10
| | | | Note that this also removed those `finish_non_exhaustive()`.
* Implement Debug for data structure as a featurenotoria2021-06-10
|
* Fix Unicode (#135)Kirawi2021-06-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Fixing Multiple Panics (#121)Kirawi2021-06-05
| | | | | | | * init * wip * wip
* Separate document history into CellIvan Tham2021-06-02
| | | | | 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.
* core: Improve changeset composition behavior.Blaž Hrastnik2021-04-06
| | | | It would fail to combine with an empty set.
* Fully drop State references.Blaž Hrastnik2021-03-31
|
* Transaction: Add a changes_iter() that can convert back to a list of ChangesBlaž Hrastnik2021-03-29
|
* Transaction: need to consume insert | delete properly.Blaž Hrastnik2021-03-29
|
* clippy lintBlaž Hrastnik2021-03-24
|
* Merge some imports.Blaž Hrastnik2021-03-22
|
* Selection: fail early if new() is called with no ranges.Blaž Hrastnik2021-03-22
|
* Implement iter() and len() directly on Selection.Blaž Hrastnik2021-03-19
|
* Remove State from a few more signatures.Blaž Hrastnik2021-03-18
|
* Make Transaction::change only rely on the rope.Blaž Hrastnik2021-03-18
|
* Cleanup: use doc.selection() instead of doc.state.selection().Blaž Hrastnik2021-03-14
|
* transaction: Also modify map_pos to work with insert|delete order.Blaž Hrastnik2021-02-18
|
* minor changesBlaž Hrastnik2021-02-17
|
* Optimize Changeset::is_empty()Blaž Hrastnik2021-02-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 } } }
* Since insert preceedes deletes, follow that ordering in Transaction::changes.Blaž Hrastnik2021-02-16
| | | | Produces the same output but will take the happy path.
* transaction: Use builder methods to generate compact changesets.Blaž Hrastnik2021-02-16
|
* transaction: Merge consecutive inserts on compose.Blaž Hrastnik2021-02-15
|
* Address clippy lints.Blaž Hrastnik2021-01-08
|