mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
lint: Use early exit/continue
This commit is contained in:
parent
ca5a4ec1d5
commit
7779132595
1 changed files with 134 additions and 134 deletions
|
@ -1398,7 +1398,10 @@ static bool handle_completions(const std::vector<completion_t> &comp,
|
|||
success = true;
|
||||
}
|
||||
|
||||
if (!done) {
|
||||
if (done) {
|
||||
return success;
|
||||
}
|
||||
|
||||
fuzzy_match_type_t best_match_type = get_best_match_type(comp);
|
||||
|
||||
// Determine whether we are going to replace the token or not. If any commands of the best
|
||||
|
@ -1412,8 +1415,8 @@ static bool handle_completions(const std::vector<completion_t> &comp,
|
|||
}
|
||||
}
|
||||
|
||||
// Decide which completions survived. There may be a lot of them; it would be nice if we
|
||||
// could figure out how to avoid copying them here.
|
||||
// Decide which completions survived. There may be a lot of them; it would be nice if we could
|
||||
// figure out how to avoid copying them here.
|
||||
std::vector<completion_t> surviving_completions;
|
||||
for (size_t i = 0; i < comp.size(); i++) {
|
||||
const completion_t &el = comp.at(i);
|
||||
|
@ -1483,7 +1486,10 @@ static bool handle_completions(const std::vector<completion_t> &comp,
|
|||
}
|
||||
}
|
||||
|
||||
if (continue_after_prefix_insertion || !use_prefix) {
|
||||
if (!continue_after_prefix_insertion && use_prefix) {
|
||||
return success;
|
||||
}
|
||||
|
||||
// We didn't get a common prefix, or we want to print the list anyways.
|
||||
size_t len, prefix_start = 0;
|
||||
wcstring prefix;
|
||||
|
@ -1493,8 +1499,7 @@ static bool handle_completions(const std::vector<completion_t> &comp,
|
|||
len = el->position - prefix_start;
|
||||
|
||||
if (will_replace_token || match_type_requires_full_replacement(best_match_type)) {
|
||||
// No prefix.
|
||||
prefix.clear();
|
||||
prefix.clear(); // no prefix
|
||||
} else if (len <= PREFIX_MAX_LEN) {
|
||||
prefix.append(el->text, prefix_start, len);
|
||||
} else {
|
||||
|
@ -1513,10 +1518,7 @@ static bool handle_completions(const std::vector<completion_t> &comp,
|
|||
// Modify the command line to reflect the new pager.
|
||||
data->pager_selection_changed();
|
||||
reader_repaint_needed();
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Return true if we believe ourselves to be orphaned. loop_count is how many times we've tried to
|
||||
|
@ -2652,7 +2654,9 @@ const wchar_t *reader_readline(int nchars) {
|
|||
}
|
||||
case R_BACKWARD_KILL_LINE: {
|
||||
editable_line_t *el = data->active_edit_line();
|
||||
if (el->position > 0) {
|
||||
if (el->position <= 0) {
|
||||
break;
|
||||
}
|
||||
const wchar_t *buff = el->text.c_str();
|
||||
const wchar_t *end = &buff[el->position];
|
||||
const wchar_t *begin = end;
|
||||
|
@ -2664,14 +2668,10 @@ const wchar_t *reader_readline(int nchars) {
|
|||
|
||||
// If we landed on a newline, don't delete it.
|
||||
if (*begin == L'\n') begin++;
|
||||
|
||||
assert(end >= begin);
|
||||
size_t len = maxi<size_t>(end - begin, 1);
|
||||
begin = end - len;
|
||||
|
||||
reader_kill(el, begin - buff, len, KILL_PREPEND,
|
||||
last_char != R_BACKWARD_KILL_LINE);
|
||||
}
|
||||
reader_kill(el, begin - buff, len, KILL_PREPEND, last_char != R_BACKWARD_KILL_LINE);
|
||||
break;
|
||||
}
|
||||
case R_KILL_WHOLE_LINE: {
|
||||
|
|
Loading…
Reference in a new issue