mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
refactor(shada.c): clint (#20599)
This commit is contained in:
@@ -454,10 +454,7 @@ static const ShadaEntry sd_default_values[] = {
|
|||||||
.additional_data = NULL),
|
.additional_data = NULL),
|
||||||
DEF_SDE(Variable, global_var,
|
DEF_SDE(Variable, global_var,
|
||||||
.name = NULL,
|
.name = NULL,
|
||||||
.value = {
|
.value = { .v_type = VAR_UNKNOWN, .vval = { .v_string = NULL } },
|
||||||
.v_type = VAR_UNKNOWN,
|
|
||||||
.vval = { .v_string = NULL }
|
|
||||||
},
|
|
||||||
.additional_elements = NULL),
|
.additional_elements = NULL),
|
||||||
DEF_SDE(GlobalMark, filemark,
|
DEF_SDE(GlobalMark, filemark,
|
||||||
.name = '"',
|
.name = '"',
|
||||||
@@ -1127,26 +1124,27 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
|
|||||||
const bool get_old_files = (flags & (kShaDaGetOldfiles | kShaDaForceit)
|
const bool get_old_files = (flags & (kShaDaGetOldfiles | kShaDaForceit)
|
||||||
&& (force || tv_list_len(oldfiles_list) == 0));
|
&& (force || tv_list_len(oldfiles_list) == 0));
|
||||||
const bool want_marks = flags & kShaDaWantMarks;
|
const bool want_marks = flags & kShaDaWantMarks;
|
||||||
const unsigned srni_flags = (unsigned)(
|
const unsigned srni_flags =
|
||||||
(flags & kShaDaWantInfo
|
(unsigned)(
|
||||||
? (kSDReadUndisableableData
|
(flags & kShaDaWantInfo
|
||||||
| kSDReadRegisters
|
? (kSDReadUndisableableData
|
||||||
| kSDReadGlobalMarks
|
| kSDReadRegisters
|
||||||
| (p_hi ? kSDReadHistory : 0)
|
| kSDReadGlobalMarks
|
||||||
| (find_shada_parameter('!') != NULL
|
| (p_hi ? kSDReadHistory : 0)
|
||||||
? kSDReadVariables
|
| (find_shada_parameter('!') != NULL
|
||||||
: 0)
|
? kSDReadVariables
|
||||||
| (find_shada_parameter('%') != NULL
|
: 0)
|
||||||
&& ARGCOUNT == 0
|
| (find_shada_parameter('%') != NULL
|
||||||
? kSDReadBufferList
|
&& ARGCOUNT == 0
|
||||||
: 0))
|
? kSDReadBufferList
|
||||||
: 0)
|
: 0))
|
||||||
| (want_marks && get_shada_parameter('\'') > 0
|
: 0)
|
||||||
? kSDReadLocalMarks | kSDReadChanges
|
| (want_marks && get_shada_parameter('\'') > 0
|
||||||
: 0)
|
? kSDReadLocalMarks | kSDReadChanges
|
||||||
| (get_old_files
|
: 0)
|
||||||
? kSDReadLocalMarks
|
| (get_old_files
|
||||||
: 0));
|
? kSDReadLocalMarks
|
||||||
|
: 0));
|
||||||
if (srni_flags == 0) {
|
if (srni_flags == 0) {
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
return;
|
return;
|
||||||
@@ -1191,17 +1189,18 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
|
|||||||
case kSDItemSearchPattern:
|
case kSDItemSearchPattern:
|
||||||
if (!force) {
|
if (!force) {
|
||||||
SearchPattern pat;
|
SearchPattern pat;
|
||||||
(cur_entry.data.search_pattern.is_substitute_pattern
|
if (cur_entry.data.search_pattern.is_substitute_pattern) {
|
||||||
? &get_substitute_pattern
|
get_substitute_pattern(&pat);
|
||||||
: &get_search_pattern)(&pat);
|
} else {
|
||||||
|
get_search_pattern(&pat);
|
||||||
|
}
|
||||||
if (pat.pat != NULL && pat.timestamp >= cur_entry.timestamp) {
|
if (pat.pat != NULL && pat.timestamp >= cur_entry.timestamp) {
|
||||||
shada_free_shada_entry(&cur_entry);
|
shada_free_shada_entry(&cur_entry);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(cur_entry.data.search_pattern.is_substitute_pattern
|
|
||||||
? &set_substitute_pattern
|
SearchPattern spat = (SearchPattern) {
|
||||||
: &set_search_pattern)((SearchPattern) {
|
|
||||||
.magic = cur_entry.data.search_pattern.magic,
|
.magic = cur_entry.data.search_pattern.magic,
|
||||||
.no_scs = !cur_entry.data.search_pattern.smartcase,
|
.no_scs = !cur_entry.data.search_pattern.smartcase,
|
||||||
.off = {
|
.off = {
|
||||||
@@ -1213,7 +1212,14 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
|
|||||||
.pat = (char_u *)cur_entry.data.search_pattern.pat,
|
.pat = (char_u *)cur_entry.data.search_pattern.pat,
|
||||||
.additional_data = cur_entry.data.search_pattern.additional_data,
|
.additional_data = cur_entry.data.search_pattern.additional_data,
|
||||||
.timestamp = cur_entry.timestamp,
|
.timestamp = cur_entry.timestamp,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (cur_entry.data.search_pattern.is_substitute_pattern) {
|
||||||
|
set_substitute_pattern(spat);
|
||||||
|
} else {
|
||||||
|
set_search_pattern(spat);
|
||||||
|
}
|
||||||
|
|
||||||
if (cur_entry.data.search_pattern.is_last_used) {
|
if (cur_entry.data.search_pattern.is_last_used) {
|
||||||
set_last_used_pattern(cur_entry.data.search_pattern.is_substitute_pattern);
|
set_last_used_pattern(cur_entry.data.search_pattern.is_substitute_pattern);
|
||||||
set_no_hlsearch(!cur_entry.data.search_pattern.highlighted);
|
set_no_hlsearch(!cur_entry.data.search_pattern.highlighted);
|
||||||
@@ -1688,8 +1694,8 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, ShadaEntr
|
|||||||
msgpack_pack_long(spacker, entry.data.filemark.mark.col);
|
msgpack_pack_long(spacker, entry.data.filemark.mark.col);
|
||||||
}
|
}
|
||||||
assert(entry.type == kSDItemJump || entry.type == kSDItemChange
|
assert(entry.type == kSDItemJump || entry.type == kSDItemChange
|
||||||
? CHECK_DEFAULT(entry, filemark.name)
|
? CHECK_DEFAULT(entry, filemark.name)
|
||||||
: true);
|
: true);
|
||||||
if (!CHECK_DEFAULT(entry, filemark.name)) {
|
if (!CHECK_DEFAULT(entry, filemark.name)) {
|
||||||
PACK_STATIC_STR(KEY_NAME_CHAR);
|
PACK_STATIC_STR(KEY_NAME_CHAR);
|
||||||
msgpack_pack_uint8(spacker, (uint8_t)entry.data.filemark.name);
|
msgpack_pack_uint8(spacker, (uint8_t)entry.data.filemark.name);
|
||||||
@@ -1699,15 +1705,14 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, ShadaEntr
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kSDItemRegister: {
|
case kSDItemRegister: {
|
||||||
const size_t map_size = (size_t)(
|
const size_t map_size = (size_t)(2 // Register contents and name
|
||||||
2 // Register contents and name
|
|
||||||
+ ONE_IF_NOT_DEFAULT(entry, reg.type)
|
+ ONE_IF_NOT_DEFAULT(entry, reg.type)
|
||||||
+ ONE_IF_NOT_DEFAULT(entry, reg.width)
|
+ ONE_IF_NOT_DEFAULT(entry, reg.width)
|
||||||
+ ONE_IF_NOT_DEFAULT(entry, reg.is_unnamed)
|
+ ONE_IF_NOT_DEFAULT(entry, reg.is_unnamed)
|
||||||
// Additional entries, if any:
|
// Additional entries, if any:
|
||||||
+ (size_t)(entry.data.reg.additional_data == NULL
|
+ (size_t)(entry.data.reg.additional_data == NULL
|
||||||
? 0
|
? 0
|
||||||
: entry.data.reg.additional_data->dv_hashtab.ht_used));
|
: entry.data.reg.additional_data->dv_hashtab.ht_used));
|
||||||
msgpack_pack_map(spacker, map_size);
|
msgpack_pack_map(spacker, map_size);
|
||||||
PACK_STATIC_STR(REG_KEY_CONTENTS);
|
PACK_STATIC_STR(REG_KEY_CONTENTS);
|
||||||
msgpack_pack_array(spacker, entry.data.reg.contents_size);
|
msgpack_pack_array(spacker, entry.data.reg.contents_size);
|
||||||
@@ -2097,8 +2102,8 @@ static inline ShaDaWriteResult shada_read_when_writing(ShaDaReadDef *const sd_re
|
|||||||
break;
|
break;
|
||||||
case kSDItemSearchPattern:
|
case kSDItemSearchPattern:
|
||||||
COMPARE_WITH_ENTRY((entry.data.search_pattern.is_substitute_pattern
|
COMPARE_WITH_ENTRY((entry.data.search_pattern.is_substitute_pattern
|
||||||
? &wms->sub_search_pattern
|
? &wms->sub_search_pattern
|
||||||
: &wms->search_pattern), entry);
|
: &wms->search_pattern), entry);
|
||||||
break;
|
break;
|
||||||
case kSDItemSubString:
|
case kSDItemSubString:
|
||||||
COMPARE_WITH_ENTRY(&wms->replacement, entry);
|
COMPARE_WITH_ENTRY(&wms->replacement, entry);
|
||||||
|
Reference in New Issue
Block a user