aboutsummaryrefslogtreecommitdiff
path: root/helix-core
Commit message (Collapse)AuthorAge
* Doc string fix in selection.rs (#6077)Alexandr2023-02-22
| | | | | | | | | | | | | * Doc string fix Delete duplicate `the` * selection.rs doc string wording * Remove extra whitespace at end of doc text --------- Co-authored-by: Ivan Tham <pickfire@riseup.net>
* Replace incorrect usages of tab_width with indent_width. (#5918)Triton1712023-02-16
|
* Prevent a panic when uncommenting a line with only a comment token (#5933)Mike Trinkala2023-02-12
| | | | | | | | | | | | | | | Open a new document `test.rs` and type the following: `di//<esc><C-c>` The margin calculation pushes the range out of bounds for the comment marker when there are no characters (newline) after it. thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Char range out of bounds: char range 0..3, Rope/RopeSlice char length 2', ropey-1.6.0/src/rope.rs:546:37 The debug build catches the error in the transaction: thread 'main' panicked at 'attempt to subtract with overflow', helix-core/src/transaction.rs:503:26
* Make `m` textobject look for pairs enclosing selections (#3344)Daniel S Poulin2023-02-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Make `m` textobject look for pairs enclosing selections Right now, this textobject only looks for pairs that surround the cursor. This ensures that the pair found encloses each selection, which is likely to be intuitively what is expected of this textobject. * Simplification of match code Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * Adjust logic for ensuring surround range encloses selection Prior, it was missing the case where the start of the selection came before the opening brace. We also had an off-by-one error where if the end of the selection was on the closing brace it would not work. * Refactor to search for the open pair specifically to avoid edge cases * Adjust wording of autoinfo to reflect new functionality * Implement tests for surround functionality in new integration style * Fix handling of skip values * Fix out of bounds error * Add `ma` version of tests * Fix formatting of tests * Reduce indentation levels for readability, and update comments * Preserve each selection's direction with enclosing pair surround * Add test case for multiple cursors resulting in overlap * Mark known failures as TODO * Make tests multi-threaded or they fail * Cargo fmt * Fix typos in integration test comments --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* Fix new clippy lints (#5892)Pascal Kuthe2023-02-09
|
* 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>
* Short-circuit the word and treesitter object movement commands (#5851)Mike Trinkala2023-02-07
| | | | | | | | | The loop always iterates the number of times the user specified even if the beginning/end of the document is reached. For an extreme demonstration try the following commands, Helix will hang for several seconds. 100000000w 100000000]c
* build(deps): bump ropey from 1.5.1 to 1.6.0 (#5859)dependabot[bot]2023-02-06
| | | | | | | | | | | | | | | | Bumps [ropey](https://github.com/cessen/ropey) from 1.5.1 to 1.6.0. - [Release notes](https://github.com/cessen/ropey/releases) - [Changelog](https://github.com/cessen/ropey/blob/master/CHANGELOG.md) - [Commits](https://github.com/cessen/ropey/compare/v1.5.1...v1.6.0) --- updated-dependencies: - dependency-name: ropey dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Fix utf8 length handling for shellwords (#5738)Mike Trinkala2023-02-01
| | | | | | | If the last argument to shellwords ends in a multibyte utf8 character the entire argument will be dropped. e.g. `:sh echo test1 test2𒀀` will only output `test1` Add additional tests based on the code review feedback
* Fix initial highlight layer sort order (#5196)Michael Davis2023-02-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The purpose of this change is to remove the mutable self borrow on `HighlightIterLayer::sort_key` so that we can sort layers with the correct ordering using the `Vec::sort` function family. `HighlightIterLayer::sort_key` needs `&mut self` since it calls `Peekable::peek` which needs `&mut self`. `Vec::sort` functions only give immutable borrows of the elements to ensure the correctness of the sort. We could instead approach this by creating an eager Peekable and using that instead of `std::iter::Peekable` to wrap `QueryCaptures`: ```rust struct EagerPeekable<I: Iterator> { iter: I, peeked: Option<I::Item>, } impl<I: Iterator> EagerPeekable<I> { fn new(mut iter: I) -> Self { let peeked = iter.next(); Self { iter, peeked } } fn peek(&self) -> Option<&I::Item> { self.peeked.as_ref() } } impl<I: Iterator> Iterator for EagerPeekable<I> { type Item = I::Item; fn next(&mut self) -> Option<Self::Item> { std::mem::replace(&mut self.peeked, self.iter.next()) } } ``` This would be a cleaner approach (notice how `EagerPeekable::peek` takes `&self` rather than `&mut self`), however this doesn't work in practice because the Items emitted by the `tree_sitter::QueryCaptures` Iterator must be consumed before the next Item is returned. `Iterator::next` on `tree_sitter::QueryCaptures` modifies the `QueryMatch` returned by the last call of `next`. This behavior is not currently reflected in the lifetimes/structure of `QueryCaptures`. This fixes an issue with layers being out of order when using combined injections since the old code only checked the first range in the layer. Layers being out of order could cause missing highlights for combined-injections content.
* rework positioning/rendering and enable softwrap/virtual text (#5420)Pascal Kuthe2023-01-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * rework positioning/rendering, enables softwrap/virtual text This commit is a large rework of the core text positioning and rendering code in helix to remove the assumption that on-screen columns/lines correspond to text columns/lines. A generic `DocFormatter` is introduced that positions graphemes on and is used both for rendering and for movements/scrolling. Both virtual text support (inline, grapheme overlay and multi-line) and a capable softwrap implementation is included. fix picker highlight cleanup doc formatter, use word bondaries for wrapping make visual vertical movement a seperate commnad estimate line gutter width to improve performance cache cursor position cleanup and optimize doc formatter cleanup documentation fix typos Co-authored-by: Daniel Hines <d4hines@gmail.com> update documentation fix panic in last_visual_line funciton improve soft-wrap documentation add extend_visual_line_up/down commands fix non-visual vertical movement streamline virtual text highlighting, add softwrap indicator fix cursor position if softwrap is disabled improve documentation of text_annotations module avoid crashes if view anchor is out of bounds fix: consider horizontal offset when traslation char_idx -> vpos improve default configuration fix: mixed up horizontal and vertical offset reset view position after config reload apply suggestions from review disabled softwrap for very small screens to avoid endless spin fix wrap_indicator setting fix bar cursor disappearring on the EOF character add keybinding for linewise vertical movement fix: inconsistent gutter highlights improve virtual text API make scope idx lookup more ergonomic allow overlapping overlays correctly track char_pos for virtual text adjust configuration deprecate old position fucntions fix infinite loop in highlight lookup fix gutter style fix formatting document max-line-width interaction with softwrap change wrap-indicator example to use empty string fix: rare panic when view is in invalid state (bis) * Apply suggestions from code review Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * improve documentation for positoning functions * simplify tests * fix documentation of Grapheme::width * Apply suggestions from code review Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * add explicit drop invocation * Add explicit MoveFn type alias * add docuntation to Editor::cursor_cache * fix a few typos * explain use of allow(deprecated) * make gj and gk extend in select mode * remove unneded debug and TODO * mark tab_width_at #[inline] * add fast-path to move_vertically_visual in case softwrap is disabled * rename first_line to first_visual_line * simplify duplicate if/else --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* build(deps): bump ahash from 0.8.2 to 0.8.3 (#5743)dependabot[bot]2023-01-30
| | | | | | | | | | | | | | | Bumps [ahash](https://github.com/tkaitchuck/ahash) from 0.8.2 to 0.8.3. - [Release notes](https://github.com/tkaitchuck/ahash/releases) - [Commits](https://github.com/tkaitchuck/ahash/compare/v0.8.2...v0.8.3) --- updated-dependencies: - dependency-name: ahash dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps): bump toml from 0.6.0 to 0.7.0 (#5726)alice2023-01-30
|
* Fix compatibility with toml 0.6.0Michael Davis2023-01-24
| | | | | | | | | | | | | `toml::from_slice` has been removed. The CHANGELOG recommends using `toml::from_str` instead and doing the byte-to-str conversion yourself. The `toml::toml!` macro has also changed to return the type of the value declared within the macro body. In the change in `helix-view/src/theme.rs` this is a `toml::map::Map` (it was a `toml::Value` previously) allowing us to skip the match and use the map directly. Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
* build(deps): bump toml from 0.5.10 to 0.6.0dependabot[bot]2023-01-24
| | | | | | | | | | | | | | | Bumps [toml](https://github.com/toml-rs/toml) from 0.5.10 to 0.6.0. - [Release notes](https://github.com/toml-rs/toml/releases) - [Commits](https://github.com/toml-rs/toml/compare/toml-v0.5.10...toml-v0.6.0) --- updated-dependencies: - dependency-name: toml dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
* build(deps): bump hashbrown from 0.13.1 to 0.13.2 (#5559)dependabot[bot]2023-01-17
| | | | | | | | | | | | | | | | | | Bumps [hashbrown](https://github.com/rust-lang/hashbrown) from 0.13.1 to 0.13.2. - [Release notes](https://github.com/rust-lang/hashbrown/releases) - [Changelog](https://github.com/rust-lang/hashbrown/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/hashbrown/compare/v0.13.1...v0.13.2) --- updated-dependencies: - dependency-name: hashbrown dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Separate jump behavior from increment/decrement (#4123)greg-enbala2023-01-16
| | | | | | | | | | | | | | increment/decrement (C-a/C-x) had some buggy behavior where selections could be offset incorrectly or the editor could panic with some edits that changed the number of characters in a number or date. These stemmed from the automatic jumping behavior which attempted to find the next date or integer to increment. The jumping behavior also complicated the code quite a bit and made the behavior somewhat difficult to predict when using many cursors. This change removes the automatic jumping behavior and only increments or decrements when the full text in a range of a selection is a number or date. This simplifies the code and fixes the panics and buggy behaviors from changing the number of characters.
* build(deps): bump ropey from 1.5.1-alpha to 1.5.1 (#5374)dependabot[bot]2023-01-03
| | | | | | | | | | | | | | | | | | Bumps [ropey](https://github.com/cessen/ropey) from 1.5.1-alpha to 1.5.1. - [Release notes](https://github.com/cessen/ropey/releases) - [Changelog](https://github.com/cessen/ropey/blob/master/CHANGELOG.md) - [Commits](https://github.com/cessen/ropey/commits/v1.5.1) --- updated-dependencies: - dependency-name: ropey dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* build(deps): bump once_cell from 1.16.0 to 1.17.0 (#5373)dependabot[bot]2023-01-03
| | | | | | | | | | | | | | | | | | Bumps [once_cell](https://github.com/matklad/once_cell) from 1.16.0 to 1.17.0. - [Release notes](https://github.com/matklad/once_cell/releases) - [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md) - [Commits](https://github.com/matklad/once_cell/compare/v1.16.0...v1.17.0) --- updated-dependencies: - dependency-name: once_cell dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Fix erroneous indent between closers of auto-pairs (#5330)Triton1712022-12-29
| | | inserting a newline between 2 closers of an auto-pair.
* Add command to merge consecutive ranges in selection (#5047)DylanBulfin2022-12-23
|
* properly handle detachted git worktrees (#5097)Pascal Kuthe2022-12-11
|
* allow specifying environment for language servers in language.toml (#4004)TotalKrill2022-12-09
| | | | | Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> Co-authored-by: Stephen Wakely <fungus.humungus@gmail.com> Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* Fix transaction composition order in History::changes_since (#4981)Michael Davis2022-12-03
| | | | | | | | | | | * Add a undo/redo split test case for crossing branches * history: Switch up/down transaction chaining order The old code tends to work in practice because, usually, either up_txns or down_txns are empty. When both have contents though, we can run into a panic trying to compose them all since they will disagree on the length of the text. This fixes the panic test case in the parent commit.
* feat(lsp): add support for lsp Diagnostic{}.data (#4935)sigmaSd2022-12-02
|
* Show (git) diff signs in gutter (#3890)Pascal Kuthe2022-12-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Show (git) diff signs in gutter (#3890) Avoid string allocation when git diffing Incrementally diff using changesets refactor diffs to be provider indepndent and improve git implementation remove dependency on zlib-ng switch to asynchronus diffing with similar Update helix-vcs/Cargo.toml fix toml formatting Co-authored-by: Ivan Tham <pickfire@riseup.net> fix typo in documentation use ropey reexpors from helix-core fix crash when creating new file remove useless use if io::Cursor fix spelling mistakes implement suggested improvement to repository loading improve git test isolation remove lefover comments Co-authored-by: univerz <univerz@fu-solution.com> fixed spelling mistake minor cosmetic changes fix: set self.differ to None if decoding the diff_base fails fixup formatting Co-authored-by: Ivan Tham <pickfire@riseup.net> reload diff_base when file is reloaded from disk switch to imara-diff Fixup formatting Co-authored-by: Blaž Hrastnik <blaz@mxxn.io> Redraw buffer whenever a diff is updated. Only store hunks instead of changes for individual lines to easily allow jumping between them Update to latest gitoxide version Change default diff gutter position Only update gutter after timeout * update diff gutter synchronously, with a timeout * Apply suggestions from code review Co-authored-by: Blaž Hrastnik <blaz@mxxn.io> Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * address review comments and ensure lock is always aquired * remove configuration for redraw timeout Co-authored-by: Blaž Hrastnik <blaz@mxxn.io> Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* Use lowest common ancestor search in History::changes_sinceMichael Davis2022-11-29
|
* delete outdated reference to cessen/ropey#25 (#4928)Kirawi2022-11-29
|
* Significantly improve performance of `:reload` (#4457)Pascal Kuthe2022-11-28
| | | | | * bump ropey to 1.5.1-alpha * significantly improve performance of :reload
* bump ropey to 1.5.1-alphaPascal Kuthe2022-11-28
|
* Follow parent links when calculating changes since a revisionMichael Davis2022-11-24
| | | | | | The 'revisions' field on History can't be treated as linear: each Revision in the revisions Vec has a parent link and an optional child link. We can follow those to unroll the recent history.
* Apply inversions to Views on undo/redoMichael Davis2022-11-24
| | | | | | | | When using undo/redo, the history revision can be decremented. In that case we should apply the inversions since the given revision in History::changes_since. This prevents panics with jumplist operations when a session uses undo/redo to move the jumplist selection outside of the document.
* Apply transactions to all views (#4733)Michael Davis2022-11-23
| | | | | | | | | | | | | | | | | * Add a test case for updating jumplists across windows * Apply transactions to all views on history changes This ensures that jumplist selections follow changes in documents, even when there are multiple views (for example a split where both windows edit the same document). * Leave TODOs for cleaning up View::apply * Use Iterator::reduce to compose history transactions Co-authored-by: Blaž Hrastnik <blaz@mxxn.io> Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* significantly improve treesitter performance while editing large files (#4716)Pascal Kuthe2022-11-22
| | | | | | | | | | | * significantly improve treesitter performance while editing large files * Apply stylistic suggestions from code review Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * use PartialEq and Hash instead of a freestanding function Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* Bump TREE_SITTER_MATCH_LIMIT to 256 (#4830)Michael Davis2022-11-21
| | | | | The limit of 64 breaks some highlighting in Erlang files with complicated record definitions. Bumping to 256 seems to work on all files I have seen.
* Use TreeCursor to pretty-print :tree-sitter-subtree (#4606)Michael Davis2022-11-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current `:tree-sitter-subtree` has a bug for field-names when the field name belongs to an unnamed child node. Take this ruby example: def self.method_name true end The subtree given by tree-sitter-cli is: (singleton_method [2, 0] - [4, 3] object: (self [2, 4] - [2, 8]) name: (identifier [2, 9] - [2, 20]) body: (body_statement [3, 2] - [3, 6] (true [3, 2] - [3, 6]))) But the `:tree-sitter-subtree` output was (singleton_method object: (self) body: (identifier) (body_statement (true))) The `singleton_method` rule defines the `name` and `body` fields in an unnamed helper rule `_method_rest` and the old implementation of `pretty_print_tree_impl` would pass the `field_name` down from the named `singleton_method` node. To fix it we switch to the [TreeCursor] API which is recommended by the tree-sitter docs for traversing the tree. `TreeCursor::field_name` accurately determines the field name for the current cursor position even when the node is unnamed. [TreeCursor]: https://docs.rs/tree-sitter/0.20.9/tree_sitter/struct.TreeCursor.html
* Capture word parts while calculating shellwords (#4632)Michael Davis2022-11-17
| | | | | | | | | | | | | | | | | | | This fixes an edge case for completing shellwords. With a file "a b.txt" in the current directory, the sequence `:open a\<tab>` will result in the prompt containing `:open aa\ b.txt`. This is because the length of the input which is trimmed when replacing with completion is calculated on the part of the input which is parsed by shellwords and then escaped (in a separate operation), which is lossy. In this case it loses the trailing backslash. The fix provided here refactors shellwords to track both the _words_ (shellwords with quotes and escapes resolved) and the _parts_ (chunks of the input which turned into each word, with separating whitespace removed). When calculating how much of the input to delete when replacing with the completion item, we now use the length of the last part. This also allows us to eliminate the duplicate work done in the `ends_with_whitespace` check.
* Fix deprecation warnings for chrono 0.4.23 (#4738)dxtr852022-11-15
| | | Co-authored-by: dxtr <dxtr@W540.mito>
* Refactor blackhole register (#4504)ath32022-11-15
|
* deps: Update tree-sitter-rust (supports let-else && let-chains)Alexis (Poliorcetics) Bourget2022-11-12
|
* improve performance of tree sitter query captures (for text object motions ↵Pascal Kuthe2022-11-11
| | | | | | | | | | | | | | | | in particular) (#4707) * add tree sitter match limit to avoid slowdowns for larger files Affects all tree sitter queries and should speedup both syntax highlighting and text object queries. This has been shown to fix significant slowdowns with textobjects for rust files as small as 3k loc. * Apply suggestions from code review Co-authored-by: Blaž Hrastnik <blaz@mxxn.io> Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* Fix panic from indenting on tree with errorsMichael Davis2022-11-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `deepest_preceding` is known to be a descendant of `node`. Repeated calls of `Node::parent` _should_ eventually turn `deepest_preceding` into `node`, but when the node is errored (the tree contains a syntax error), `Node::parent` returns None. In the typescript case: if(true) &&true // ^ press enter here The tree is: (program [0, 0] - [1, 0] (if_statement [0, 0] - [0, 15] condition: (parenthesized_expression [0, 2] - [0, 8] (true [0, 3] - [0, 7])) consequence: (expression_statement [0, 8] - [0, 15] (binary_expression [0, 8] - [0, 15] left: (identifier [0, 8] - [0, 8]) right: (true [0, 11] - [0, 15]))))) `node` is the `program` node and `deepest_preceding` is the `binary_expression`. The tree is errored on the `binary_expression` node with `(MISSING identifier [0, 8] - [0, 8])`. In the C++ case: ; << // press enter after the ';' The tree is: (translation_unit [0, 0] - [1, 0] (expression_statement [0, 0] - [0, 1]) (ERROR [0, 1] - [0, 4] (identifier [0, 1] - [0, 1]))) `node` is the `translation_unit` and `deepest_preceding` is the `ERROR` node. In both cases, `Node::parent` on the errored node returns None.
* style: Only call extend_nodes when deepest_preceding is SomeMichael Davis2022-11-09
|
* fix testsBlaž Hrastnik2022-11-08
|
* fix testsBlaž Hrastnik2022-11-08
|
* core: Move state into the history moduleBlaž Hrastnik2022-11-08
|
* Run clippy on workspace in CI (#4614)Jonathan LEI2022-11-07
|
* Escape filenames in command completionMichael Davis2022-11-07
| | | | | | This changes the completion items to be rendered with shellword escaping, so a file `a b.txt` is rendered as `a\ b.txt` which matches how it should be inputted.
* Fix whitespace handling in command-mode completionMichael Davis2022-11-07
| | | | | | | | | | 8584b38cfbe6ffe3e5d539ad953c413e44e90bfa switched to shellwords for completion in command-mode. This changes the conditions for choosing whether to complete the command or use the command's completer. This change processes the input as shellwords up-front and uses shellword logic about whitespace to determine whether the command or argument should be completed.
* Resolve a bunch of upcoming clippy lintsBlaž Hrastnik2022-11-04
|