diff options
author | ZyX <kp-pav@yandex.ru> | 2015-08-11 01:28:05 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2015-10-08 22:00:37 +0300 |
commit | 0a334f9d33e2b68ce39216207b574d894dd182f4 (patch) | |
tree | 8bf23fa388fd685d022f164216a6f7be2e9ed2a0 /src | |
parent | fcb3e96cbdaa49472abde3cbf8792c12a46e2082 (diff) | |
download | rneovim-0a334f9d33e2b68ce39216207b574d894dd182f4.tar.gz rneovim-0a334f9d33e2b68ce39216207b574d894dd182f4.tar.bz2 rneovim-0a334f9d33e2b68ce39216207b574d894dd182f4.zip |
shada: Merge changes regardless whether they are from current instance
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/shada.c | 75 |
1 files changed, 36 insertions, 39 deletions
diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 8f731e7eda..6551e319d2 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -394,7 +394,6 @@ typedef struct { ShadaEntry *additional_marks; ///< All marks with unknown names. size_t additional_marks_size; ///< Size of the additional_marks array. Timestamp greatest_timestamp; ///< Greatest timestamp among marks. - bool is_local_entry; ///< True if structure comes from the current session. } FileMarks; KHASH_MAP_INIT_STR(file_marks, FileMarks) @@ -2506,7 +2505,6 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, kh_key(&wms->file_marks, k) = xstrdup(fname); memset(filemarks, 0, sizeof(*filemarks)); } - filemarks->is_local_entry = true; do { fmark_T fm; char name; @@ -2701,48 +2699,47 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, COMPARE_WITH_ENTRY(&filemarks->marks[idx], entry); } } else { - if (filemarks->is_local_entry) { - shada_free_shada_entry(&entry); - } else { - const int cl_len = (int) filemarks->changes_size; - int i; - for (i = cl_len; i > 0; i--) { - const ShadaEntry old_entry = filemarks->changes[i - 1].data; - if (old_entry.timestamp <= entry.timestamp) { - if (marks_equal(old_entry.data.filemark.mark, - entry.data.filemark.mark)) { - i = -1; - } - break; - } - } - if (i > 0) { - if (cl_len == JUMPLISTSIZE) { - if (filemarks->changes[0].can_free_entry) { - shada_free_shada_entry(&filemarks->changes[0].data); - } - memmove(&filemarks->changes[0], &filemarks->changes[1], - sizeof(filemarks->changes[0]) * (size_t) i); - } else if (i == 0) { - if (cl_len == JUMPLISTSIZE) { - i = -1; - } else { - memmove(&filemarks->changes[1], &filemarks->changes[0], - sizeof(filemarks->changes[0]) * (size_t) cl_len); - } + const int cl_len = (int) filemarks->changes_size; + int i; + for (i = cl_len; i > 0; i--) { + const ShadaEntry old_entry = filemarks->changes[i - 1].data; + if (old_entry.timestamp <= entry.timestamp) { + if (marks_equal(old_entry.data.filemark.mark, + entry.data.filemark.mark)) { + i = -1; } + break; } - if (i != -1) { - filemarks->changes[i] = (PossiblyFreedShadaEntry) { - .can_free_entry = true, - .data = entry - }; - if (cl_len < JUMPLISTSIZE) { - filemarks->changes_size++; + } + if (i > 0) { + if (cl_len == JUMPLISTSIZE) { + if (filemarks->changes[0].can_free_entry) { + shada_free_shada_entry(&filemarks->changes[0].data); } + memmove(&filemarks->changes[0], &filemarks->changes[1], + sizeof(filemarks->changes[0]) * (size_t) i); } else { - shada_free_shada_entry(&entry); + memmove(&filemarks->changes[i + 1], &filemarks->changes[i], + sizeof(filemarks->changes[0]) * (size_t) (cl_len - i)); } + } else if (i == 0) { + if (cl_len == JUMPLISTSIZE) { + i = -1; + } else if (cl_len > 0) { + memmove(&filemarks->changes[1], &filemarks->changes[0], + sizeof(filemarks->changes[0]) * (size_t) cl_len); + } + } + if (i != -1) { + filemarks->changes[i] = (PossiblyFreedShadaEntry) { + .can_free_entry = true, + .data = entry + }; + if (cl_len < JUMPLISTSIZE) { + filemarks->changes_size++; + } + } else { + shada_free_shada_entry(&entry); } } break; |