aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/position.rs
Commit message (Collapse)AuthorAge
* Fix typos (#6643)Daniel Sedlak2023-04-07
|
* Fix clippy lints (#6454)Philipp Mildenberger2023-03-27
|
* respect line annotations in char_idx_at_visual_row_offsetPascal Kuthe2023-03-27
| | | | | | | | | | | | | | char_idx_at_visual_row_offset asssumed that a single line/block break always corresponded to a vertical offset of 1. However conceal can hide the line break (in which case the certical offset would be 0) and line annotations (or softwrapped inlay hints at the end of the line) can insert addtional vertical lines. To correctly account for these cases we simply compute the visual offset of the start of the next block from the previous block instead of the visual offset of the block end. This means that the line breaks at the end of the block (however many there may be) are automatically included and we don't need to manually add 1 to the `row_offset` anymore.
* fix view anchors not at start of a visual linePascal Kuthe2023-03-27
| | | | | | | | | | | | | | | | | | | | | The top of a view is marked by a char idx anchor. That char idx is usually the first character of the visual line it's on. We use a char index instead of a line index because the view may start in the middle of a line with soft wrapping. However, it's possible to temporarily endup in a state where this anchor is not the first character of the first visual line. This is pretty rare because edits usually happen inside/after the view. In most cases we handle this case correctly. However, if the cursor is before the anchor (but still in view) there can be crashes or visual artifacts. This is caused by the fact that visual_offset_from_anchor (and the positioning code in view.rs) incorrectly assumed that the (cursor) position is always after the view anchor if the cursor is in view. But if the anchor is not the first character of the first visual line this is not the case anymore. In that case crashes and visual artifacts are possible. This commit fixes that problem by changing `visual_offset_from_anchor` (and callsites) to properly consider that case.
* 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>
* feat: make `move_vertically` aware of tabs and wide characters (#2620)Matthew Toohey2022-06-21
| | | | | | | | | | | | | * feat: make `move_vertically` aware of tabs and wide characters * refactor: replace unnecessary checked_sub with comparison * refactor: leave pos_at_coords unchanged and introduce separate pos_at_visual_coords * style: include comment to explain `pos_at_visual_coords` breaking condition * refactor: use `pos_at_visual_coords` in `text_pos_at_screen_coords` * feat: make `copy_selection_on_line` aware of wide characters
* Fix tab rendering to use dynamic tab widthBlaž Hrastnik2022-03-04
| | | | | | Each tab is just wide enough to round to the nearest tab stop. Refs #1243
* Reuse visual_coords_at_pos function in viewBlaž Hrastnik2022-03-04
|
* Allow specifying file start position (#445)Ivan Tham2022-01-23
| | | Like helix-term/src/commands.rs:3426:15
* Ensure coords in screen depends on char width (#885)Ivan Tham2021-11-03
| | | | | The issue affected files with lots of tabs at the start as well. Fix #840
* Document `pos_at_coords` better.Nathan Vegdahl2021-08-09
| | | | | Particularly the effect of the `limit_before_line_ending` parameter.
* Revert display-width-based vertical cursor movement.Nathan Vegdahl2021-07-22
| | | | Still needs to be done, but should be part of a separate PR.
* Fixes for misc bugs with view movement.Nathan Vegdahl2021-07-21
|
* Make vertical selection movement work properly.Nathan Vegdahl2021-07-06
|
* 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.
* Work on moving code over to LineEnding instead of assuming '\n'.Nathan Vegdahl2021-06-20
| | | | Also some general cleanup and some minor fixes along the way.
* clippy lintBlaž Hrastnik2021-03-24
|
* Move things out of state.rs.Blaž Hrastnik2021-03-18
|
* nix: include rust-src so rust-analyzer works correctly.Blaž Hrastnik2021-01-19
|
* Incremental parsing: rough draft.Blaž Hrastnik2020-09-17
|
* Implement a new core based on CodeMirror.Blaž Hrastnik2020-05-25
|
* Initial import.Blaž Hrastnik2020-05-20