mirror of
https://github.com/helix-editor/helix.git
synced 2025-01-18 13:07:06 +04:00
3318953bf6
This is partially a style commit: * Pull more bindings out the `change_by_selection` closure like the line-ending string and the comment tokens used for continuation. * Prefer `Editor::config` to `Document`'s config. The rest is changes to places where `insert_newline` may allocate. The first is to move `new_text` out of the `change_by_selection` closure, reusing it between iterations. This is not necessarily always an improvement as we need to clone the text for the return type of the closure. `SmartString`'s `From<String>` implementation reuses the allocation when the string is too long to inline and drops it if it is short enough to inline though which can be wasteful. `From<&String>` clones the string's allocation only when it is too long to be inlined, so we save on allocations for any `new_text` short enough to be inlined. The rest is changes to `new_text.reserve_exact`. Previously calls to this function in this block mixed up character and byte indexing by treating the length of the line-ending as 1. `reserve_exact` takes a number of bytes to reserve and that may be 2 when `line_ending` is a CRLF. A call to `reserve_exact` is also added to the branch used when continuing line comments. |
||
---|---|---|
.. | ||
src | ||
tests | ||
.gitignore | ||
build.rs | ||
Cargo.toml |