mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 17:36:29 +00:00
shada: Do not save search pattern/sub string when it is older
This commit is contained in:
@@ -1021,6 +1021,16 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kSDItemSearchPattern: {
|
case kSDItemSearchPattern: {
|
||||||
|
if (!force) {
|
||||||
|
SearchPattern pat;
|
||||||
|
(cur_entry.data.search_pattern.is_substitute_pattern
|
||||||
|
? &get_substitute_pattern
|
||||||
|
: &get_search_pattern)(&pat);
|
||||||
|
if (pat.pat != NULL && pat.timestamp >= cur_entry.timestamp) {
|
||||||
|
shada_free_shada_entry(&cur_entry);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
(cur_entry.data.search_pattern.is_substitute_pattern
|
(cur_entry.data.search_pattern.is_substitute_pattern
|
||||||
? &set_substitute_pattern
|
? &set_substitute_pattern
|
||||||
: &set_search_pattern)((SearchPattern) {
|
: &set_search_pattern)((SearchPattern) {
|
||||||
@@ -1046,6 +1056,14 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kSDItemSubString: {
|
case kSDItemSubString: {
|
||||||
|
if (!force) {
|
||||||
|
SubReplacementString sub;
|
||||||
|
sub_get_replacement(&sub);
|
||||||
|
if (sub.sub != NULL && sub.timestamp >= cur_entry.timestamp) {
|
||||||
|
shada_free_shada_entry(&cur_entry);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
sub_set_replacement((SubReplacementString) {
|
sub_set_replacement((SubReplacementString) {
|
||||||
.sub = cur_entry.data.sub_string.sub,
|
.sub = cur_entry.data.sub_string.sub,
|
||||||
.timestamp = cur_entry.timestamp,
|
.timestamp = cur_entry.timestamp,
|
||||||
@@ -1679,6 +1697,10 @@ static void shada_write(ShaDaWriteDef *const sd_writer,
|
|||||||
ShaDaReadDef *const sd_reader)
|
ShaDaReadDef *const sd_reader)
|
||||||
FUNC_ATTR_NONNULL_ARG(1)
|
FUNC_ATTR_NONNULL_ARG(1)
|
||||||
{
|
{
|
||||||
|
// TODO(ZyX-I): Write only one search pattern, substitute search pattern and
|
||||||
|
// substitute replacement string, which has the greatest timestamp. Make sure
|
||||||
|
// that this also applies if ShaDa file contains more then one replacement
|
||||||
|
// string.
|
||||||
khash_t(bufset) *const removable_bufs = kh_init(bufset);
|
khash_t(bufset) *const removable_bufs = kh_init(bufset);
|
||||||
int max_kbyte_i = get_shada_parameter('s');
|
int max_kbyte_i = get_shada_parameter('s');
|
||||||
if (max_kbyte_i < 0) {
|
if (max_kbyte_i < 0) {
|
||||||
@@ -1886,13 +1908,16 @@ static void shada_write(ShaDaWriteDef *const sd_writer,
|
|||||||
{
|
{
|
||||||
SubReplacementString sub;
|
SubReplacementString sub;
|
||||||
sub_get_replacement(&sub);
|
sub_get_replacement(&sub);
|
||||||
ShadaEntry sub_entry = (ShadaEntry) {
|
wms->replacement = (PossiblyFreedShadaEntry) {
|
||||||
.type = kSDItemSubString,
|
.can_free_entry = false,
|
||||||
.timestamp = sub.timestamp,
|
|
||||||
.data = {
|
.data = {
|
||||||
.sub_string = {
|
.type = kSDItemSubString,
|
||||||
.sub = (char *) sub.sub,
|
.timestamp = sub.timestamp,
|
||||||
.additional_elements = sub.additional_elements,
|
.data = {
|
||||||
|
.sub_string = {
|
||||||
|
.sub = (char *) sub.sub,
|
||||||
|
.additional_elements = sub.additional_elements,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user