aboutsummaryrefslogtreecommitdiffhomepage
path: root/reader.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-05-20 01:40:24 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-05-20 01:40:24 -0700
commit924b646b79dace609d817902093041a9cf393da6 (patch)
tree5ec93cdd93f3a4caa54a611b1cbeba5feb9aa3c1 /reader.cpp
parentf8786c25be7d52283ae2e223861956bd1d926d60 (diff)
Fix for crashing and assertion failures when tab completing a token that consists of only backslash
Diffstat (limited to 'reader.cpp')
-rw-r--r--reader.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/reader.cpp b/reader.cpp
index 5f3758b5..c3e1e5b0 100644
--- a/reader.cpp
+++ b/reader.cpp
@@ -3043,17 +3043,25 @@ const wchar_t *reader_readline(void)
else
{
/* Either the user hit tab only once, or we had no visible completion list. */
- const wchar_t *cmdsub_begin, *cmdsub_end;
- const wchar_t *token_begin, *token_end;
+
+ /* Remove a trailing backslash. This may trigger an extra repaint, but this is rare. */
+ if (is_backslashed(data->command_line, data->buff_pos))
+ {
+ remove_backward();
+ }
+
+ /* Get the string; we have to do this after removing any trailing backslash */
const wchar_t * const buff = data->command_line.c_str();
/* Clear the completion list */
comp.clear();
/* Figure out the extent of the command substitution surrounding the cursor. This is because we only look at the current command substitution to form completions - stuff happening outside of it is not interesting. */
+ const wchar_t *cmdsub_begin, *cmdsub_end;
parse_util_cmdsubst_extent(buff, data->buff_pos, &cmdsub_begin, &cmdsub_end);
/* Figure out the extent of the token within the command substitution. Note we pass cmdsub_begin here, not buff */
+ const wchar_t *token_begin, *token_end;
parse_util_token_extent(cmdsub_begin, data->buff_pos - (cmdsub_begin-buff), &token_begin, &token_end, 0, 0);
/* Figure out how many steps to get from the current position to the end of the current token. */
@@ -3066,12 +3074,6 @@ const wchar_t *reader_readline(void)
reader_repaint();
}
- /* Remove a trailing backslash. This may trigger an extra repaint, but this is rare. */
- if (is_backslashed(data->command_line, data->buff_pos))
- {
- remove_backward();
- }
-
/* Construct a copy of the string from the beginning of the command substitution up to the end of the token we're completing */
const wcstring buffcpy = wcstring(cmdsub_begin, token_end);