diff options
author | Thomas Vigouroux <tomvig38@gmail.com> | 2021-07-09 15:10:49 +0200 |
---|---|---|
committer | Thomas Vigouroux <tomvig38@gmail.com> | 2021-07-09 15:36:07 +0200 |
commit | ff53c5585f46bed9622bd4a3071c8cf3db96a9ac (patch) | |
tree | d2f172e88748cf248be97dc0a4e5218d9ca71eec /src/nvim/undo.c | |
parent | 9132b76da6c22bdd96af62113ff23e408fcc2ae7 (diff) | |
download | rneovim-ff53c5585f46bed9622bd4a3071c8cf3db96a9ac.tar.gz rneovim-ff53c5585f46bed9622bd4a3071c8cf3db96a9ac.tar.bz2 rneovim-ff53c5585f46bed9622bd4a3071c8cf3db96a9ac.zip |
refactor(undo): don't assume curbuf in u_compute_hash
Diffstat (limited to 'src/nvim/undo.c')
-rw-r--r-- | src/nvim/undo.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/nvim/undo.c b/src/nvim/undo.c index d561ca5b83..7afabc7913 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -631,18 +631,20 @@ int u_savecommon(buf_T *buf, static char_u e_not_open[] = N_("E828: Cannot open undo file for writing: %s"); -/* - * Compute the hash for the current buffer text into hash[UNDO_HASH_SIZE]. - */ -void u_compute_hash(char_u *hash) +/// Compute the hash for a buffer text into hash[UNDO_HASH_SIZE]. +/// +/// @param[in] buf The buffer used to compute the hash +/// @param[in] hash Array of size UNDO_HASH_SIZE in which to store the value of +/// the hash +void u_compute_hash(buf_T *buf, char_u *hash) { context_sha256_T ctx; linenr_T lnum; char_u *p; sha256_start(&ctx); - for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) { - p = ml_get(lnum); + for (lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) { + p = ml_get_buf(buf, lnum, false); sha256_update(&ctx, p, (uint32_t)(STRLEN(p) + 1)); } sha256_finish(&ctx, hash); |