mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Simplify split_success logic
This commit is contained in:
parent
36b4191e41
commit
0cee300194
@ -5566,12 +5566,7 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr,
|
|||||||
linenr_T highest_num_line = 0;
|
linenr_T highest_num_line = 0;
|
||||||
int col_width = 0;
|
int col_width = 0;
|
||||||
|
|
||||||
// if we fail to split the window, we don't want to modify orig_buf
|
|
||||||
bool split_success = false;
|
|
||||||
|
|
||||||
if (split && win_split((int)p_cwh, WSP_BOT) != FAIL) {
|
if (split && win_split((int)p_cwh, WSP_BOT) != FAIL) {
|
||||||
split_success = true;
|
|
||||||
|
|
||||||
buf_open_scratch(preview_buf ? bufnr : 0, "[Preview]");
|
buf_open_scratch(preview_buf ? bufnr : 0, "[Preview]");
|
||||||
buf_clear();
|
buf_clear();
|
||||||
preview_buf = curbuf;
|
preview_buf = curbuf;
|
||||||
@ -5589,6 +5584,9 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr,
|
|||||||
highest_num_line = kv_last(lines.subresults).end.lnum;
|
highest_num_line = kv_last(lines.subresults).end.lnum;
|
||||||
col_width = log10(highest_num_line) + 1 + 3;
|
col_width = log10(highest_num_line) + 1 + 3;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// if we fail to split the window, we don't want to modify the preview buffer
|
||||||
|
preview_buf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *str = NULL; // construct the line to show in here
|
char *str = NULL; // construct the line to show in here
|
||||||
@ -5601,7 +5599,7 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr,
|
|||||||
for (size_t matchidx = 0; matchidx < lines.subresults.size; matchidx++) {
|
for (size_t matchidx = 0; matchidx < lines.subresults.size; matchidx++) {
|
||||||
SubResult match = lines.subresults.items[matchidx];
|
SubResult match = lines.subresults.items[matchidx];
|
||||||
|
|
||||||
if (split_success && preview_buf) {
|
if (preview_buf) {
|
||||||
lpos_T p_start = { 0, match.start.col }; // match starts here in preview
|
lpos_T p_start = { 0, match.start.col }; // match starts here in preview
|
||||||
lpos_T p_end = { 0, match.end.col }; // ... and ends here
|
lpos_T p_end = { 0, match.end.col }; // ... and ends here
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user