aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/undo.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2021-07-09 18:52:26 +0200
committerGitHub <noreply@github.com>2021-07-09 18:52:26 +0200
commit37af69285aa10b423ddaac5176328b4728012e0a (patch)
tree7d9edabdf4356b01e4a0798e5b9e6431f264db74 /src/nvim/undo.c
parent191d3e6af7a248c86f0adde22b7768095f9c0356 (diff)
parentff53c5585f46bed9622bd4a3071c8cf3db96a9ac (diff)
downloadrneovim-37af69285aa10b423ddaac5176328b4728012e0a.tar.gz
rneovim-37af69285aa10b423ddaac5176328b4728012e0a.tar.bz2
rneovim-37af69285aa10b423ddaac5176328b4728012e0a.zip
Merge pull request #15036 from vigoux/decurbuf-2
refactor(undo): don't assume curbuf in u_compute_hash
Diffstat (limited to 'src/nvim/undo.c')
-rw-r--r--src/nvim/undo.c14
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);