zed/crates/vim/src
Ali 00c0e96e76
Some checks are pending
Congratsbot / check-author (push) Waiting to run
Congratsbot / congrats (push) Blocked by required conditions
deploy_nightly_docs / deploy_docs (push) Waiting to run
run_tests / orchestrate (push) Waiting to run
run_tests / check_style (push) Waiting to run
run_tests / clippy_windows (push) Blocked by required conditions
run_tests / clippy_linux (push) Blocked by required conditions
run_tests / clippy_mac (push) Blocked by required conditions
run_tests / clippy_mac_x86_64 (push) Blocked by required conditions
run_tests / run_tests_windows (push) Blocked by required conditions
run_tests / run_tests_linux (push) Blocked by required conditions
run_tests / run_tests_mac (push) Blocked by required conditions
run_tests / miri_scheduler (push) Blocked by required conditions
run_tests / doctests (push) Blocked by required conditions
run_tests / check_workspace_binaries (push) Blocked by required conditions
run_tests / build_visual_tests_binary (push) Blocked by required conditions
run_tests / check_wasm (push) Blocked by required conditions
run_tests / check_dependencies (push) Blocked by required conditions
run_tests / check_docs (push) Blocked by required conditions
run_tests / check_licenses (push) Blocked by required conditions
run_tests / check_scripts (push) Blocked by required conditions
run_tests / check_postgres_and_protobuf_migrations (push) Blocked by required conditions
run_tests / extension_tests (push) Blocked by required conditions
run_tests / tests_pass (push) Blocked by required conditions
Make opening large files use less peak memory (#62748)
# Objective
Opening a file laods it twice. `decode_file_text` builds the whole file
as a `String`, and that `String` stays alive alongside the finished rope
while `text::Buffer::new` copies it in. The `Vec` behind it grows by
doubling, so it also commits up to nearly the file's size again in
capacity it never uses.

Partially addresses #27283.

## Solution

Add `decode_file_text_to_rope`, which streams the file in 1 MB blocks
straight into a `Rope`, validating UTF-8 and normalizing line endings as
it goes. The file is never fully held as a `String`.

`LoadedFile::text` becomes a `Rope` carrying the `LineEnding` detected
before normalizing, so `buffer_store` calls `Buffer::new_normalized`.

## Testing

On a 729 MB SQL dump, peak memory fell 25% and CPU fell around 28%.
tested on 5950x, win11.

Release Notes:

- Improved memory use when opening large files, reducing peak memory
during load by roughly the size of the file itself.
2026-08-18 16:59:08 +00:00
..
digraph
helix editor: Keep the cursor before text inserted by on-type formatting (#61823) 2026-08-12 18:14:00 +00:00
normal editor: Align selections by display position instead of byte column (#61997) 2026-08-14 00:20:27 +00:00
test
change_list.rs
command.rs Make opening large files use less peak memory (#62748) 2026-08-18 16:59:08 +00:00
digraph.rs
helix.rs helix: Add vim::HelixGotoLine action and bind it to G (#61581) 2026-08-13 12:34:28 +00:00
indent.rs
insert.rs Fix Helix append escape cursor restore (#57736) 2026-07-28 13:31:57 +00:00
mode_indicator.rs
motion.rs editor: Keep the cursor before text inserted by on-type formatting (#61823) 2026-08-12 18:14:00 +00:00
normal.rs vim: Fix insert above auto-indentation (#52594) 2026-08-04 11:45:33 +00:00
object.rs treesitter: Worker-pinned treesitter parsing (#62784) 2026-08-18 16:55:09 +00:00
replace.rs
rewrap.rs
state.rs picker: Simplify presentation and sizing APIs, add preview-aware defaults (#59719) 2026-06-23 09:33:47 +00:00
surrounds.rs editor: Keep the cursor before text inserted by on-type formatting (#61823) 2026-08-12 18:14:00 +00:00
test.rs vim: Fix cursor placement after switching to Helix normal mode with a multi-key binding (#62080) 2026-08-05 11:03:09 +00:00
vim.rs editor: Keep the cursor before text inserted by on-type formatting (#61823) 2026-08-12 18:14:00 +00:00
visual.rs editor: Keep the cursor before text inserted by on-type formatting (#61823) 2026-08-12 18:14:00 +00:00