mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-19 18:13:00 +08:00
Fix for issue where backward kill line crashes if performed while the cursor is on a newline
https://github.com/fish-shell/fish-shell/pull/580
This commit is contained in:
parent
8b40f09e17
commit
911c37e63e
13
reader.cpp
13
reader.cpp
|
@ -3101,18 +3101,23 @@ const wchar_t *reader_readline()
|
|||
const wchar_t *buff = data->command_line.c_str();
|
||||
const wchar_t *end = &buff[data->buff_pos];
|
||||
const wchar_t *begin = end;
|
||||
|
||||
|
||||
/* Make sure we delete at least one character (see #580) */
|
||||
begin--;
|
||||
|
||||
/* Delete until we hit a newline, or the beginning of the string */
|
||||
while (begin > buff && *begin != L'\n')
|
||||
begin--;
|
||||
|
||||
|
||||
/* 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(begin - buff, len, KILL_PREPEND, last_char!=R_BACKWARD_KILL_LINE);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user