mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
lint: Use early exit/continue
This commit is contained in:
parent
46b791240a
commit
d441de33e5
1 changed files with 41 additions and 39 deletions
|
@ -105,10 +105,15 @@ static bool allow_soft_wrap(void) {
|
|||
|
||||
/// Does this look like the escape sequence for setting a screen name.
|
||||
static bool is_screen_name_escape_seq(const wchar_t *code, size_t *resulting_length) {
|
||||
bool found = false;
|
||||
if (code[1] == L'k') {
|
||||
if (code[1] != L'k') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const env_var_t term_name = env_get_string(L"TERM");
|
||||
if (!term_name.missing() && string_prefixes_string(L"screen", term_name)) {
|
||||
if (term_name.missing() || !string_prefixes_string(L"screen", term_name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const wchar_t *const screen_name_end_sentinel = L"\x1b\\";
|
||||
const wchar_t *screen_name_end = wcsstr(&code[2], screen_name_end_sentinel);
|
||||
if (screen_name_end == NULL) {
|
||||
|
@ -119,10 +124,7 @@ static bool is_screen_name_escape_seq(const wchar_t *code, size_t *resulting_len
|
|||
screen_name_end + wcslen(screen_name_end_sentinel);
|
||||
*resulting_length = escape_sequence_end - code;
|
||||
}
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// iTerm2 escape codes: CSI followed by ], terminated by either BEL or escape + backslash.
|
||||
|
@ -169,8 +171,10 @@ static bool is_two_byte_escape_seq(const wchar_t *code, size_t *resulting_length
|
|||
/// Generic VT100 CSI-style sequence. <esc>, followed by zero or more ASCII characters NOT in
|
||||
/// the range [@,_], followed by one character in that range.
|
||||
static bool is_csi_style_escape_seq(const wchar_t *code, size_t *resulting_length) {
|
||||
bool found = false;
|
||||
if (code[1] == L'[') {
|
||||
if (code[1] != L'[') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Start at 2 to skip over <esc>[
|
||||
size_t cursor = 2;
|
||||
for (; code[cursor] != L'\0'; cursor++) {
|
||||
|
@ -186,11 +190,9 @@ static bool is_csi_style_escape_seq(const wchar_t *code, size_t *resulting_lengt
|
|||
break;
|
||||
}
|
||||
}
|
||||
// curs now indexes just beyond the end of the sequence (or at the terminating zero).
|
||||
found = true;
|
||||
// cursor now indexes just beyond the end of the sequence (or at the terminating zero).
|
||||
*resulting_length = cursor;
|
||||
}
|
||||
return found;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Returns the number of characters in the escape code starting at 'code' (which should initially
|
||||
|
@ -817,7 +819,7 @@ static void s_update(screen_t *scr, const wchar_t *left_prompt, const wchar_t *r
|
|||
}
|
||||
|
||||
// Output any rprompt if this is the first line.
|
||||
if (i == 0 && right_prompt_width > 0) {
|
||||
if (i == 0 && right_prompt_width > 0) { //!OCLINT(Use early exit/continue)
|
||||
s_move(scr, &output, (int)(screen_width - right_prompt_width), (int)i);
|
||||
s_set_color(scr, &output, 0xffffffff);
|
||||
s_write_str(&output, right_prompt);
|
||||
|
|
Loading…
Reference in a new issue