You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
helix/helix-core/src
Pascal Kuthe e604d9f8e0
keep (cursor) position when exactly replacing text (#5930)
Whenever a document is changed helix maps various positions like the
cursor or diagnostics through the `ChangeSet` applied to the document.

Currently, this mapping handles replacements as follows:

* Move position to the left for `Assoc::Before` (start of selection)
* Move position to the right for `Assoc::After` (end of selection)

However, when text is exactly replaced this can produce weird results
where the cursor is moved when it shouldn't. For example if `foo` is
selected and a separate cursor is placed on each character (`s.<ret>`)
and the text is replaced (for example `rx`) then the cursors are moved
to the side instead of remaining in place.

This change adds a special case to the mapping code of replacements:
If the deleted and inserted text have the same (char) length then
the position is returned as if the replacement doesn't exist.

only keep selections invariant under replacement

Keeping selections unchanged if they are inside an exact replacement
is intuitive. However, for diagnostics this is not desirable as
helix would otherwise fail to remove diagnostics if replacing parts
of the document.
4 months ago
..
doc_formatter correctly wrap at text-width 4 months ago
increment Use non-deprecated chrono Duration functions 9 months ago
syntax Fix finding injection layer in tree cursor with nested layers (#11365) 4 months ago
auto_pairs.rs chore: clean up clippy lints (#11377) 4 months ago
chars.rs Revert "Replace unicode-general-category with icu-properties (#10989)" (#11006) 5 months ago
comment.rs toggling of block comments (#4718) 9 months ago
config.rs Add glob file type support (#8006) 10 months ago
diagnostic.rs render diagnostic inline 4 months ago
diff.rs delete outdated reference to cessen/ropey#25 (#4928) 2 years ago
doc_formatter.rs fix typo in doc_formatter.rs 4 months ago
fuzzy.rs Bump nucleo to v0.4.1 4 months ago
graphemes.rs render diagnostic inline 4 months ago
history.rs Prefer RopeSlice to &Rope in helix_core::syntax 1 year ago
indent.rs chore: clean up clippy lints (#11377) 4 months ago
lib.rs render diagnostic inline 4 months ago
line_ending.rs Add config for default line ending (#5621) 1 year ago
macros.rs Split parts of helix-term into helix-view. 4 years ago
match_brackets.rs Add curly single and double quotes to BRACKETS (#10971) 5 months ago
movement.rs Add commands for movement by subwords (#8147) 4 months ago
object.rs specify direction for select_prev_sibling and select_next_sibling (#10542) 7 months ago
position.rs fix scrolling/movement for multiline virtual text 4 months ago
rope_reader.rs search buffer contents during global search (#5652) 1 year ago
search.rs Jump to the next number on the line before incrementing (#1778) 3 years ago
selection.rs keep (cursor) position when exactly replacing text (#5930) 4 months ago
shellwords.rs Fix typos (#6643) 2 years ago
surround.rs test: match around closest pair tree-sitter version 7 months ago
syntax.rs chore: clean up clippy lints (#11377) 4 months ago
test.rs fix test::plain 2 years ago
text_annotations.rs ignore empty virtual text layers 4 months ago
textobject.rs test: match around closest pair tree-sitter version 7 months ago
transaction.rs keep (cursor) position when exactly replacing text (#5930) 4 months ago
uri.rs Convert LSP URIs into custom URIs 4 months ago
wrap.rs don't break on hyphen with :reflow (#8569) 1 year ago