aboutsummaryrefslogtreecommitdiffhomepage
path: root/reader.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-05-24 23:53:10 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-05-24 23:56:12 -0700
commitee95a7309a5e89031188642c8c2e4c77283d6433 (patch)
treef67b1c2357139660816c32042bad8539b64d4e38 /reader.cpp
parentf32dfe2da60e7da56a15d9ceea1145f4905b777f (diff)
Fix issue where transpose fails if there is a trailing autosuggestion
Diffstat (limited to 'reader.cpp')
-rw-r--r--reader.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/reader.cpp b/reader.cpp
index 2a26b050..c5141466 100644
--- a/reader.cpp
+++ b/reader.cpp
@@ -3043,7 +3043,7 @@ const wchar_t *reader_readline(void)
else
{
/* Either the user hit tab only once, or we had no visible completion list. */
-
+
/* Remove a trailing backslash. This may trigger an extra repaint, but this is rare. */
if (is_backslashed(data->command_line, data->buff_pos))
{
@@ -3544,7 +3544,8 @@ const wchar_t *reader_readline(void)
case R_TRANSPOSE_CHARS:
{
- if (data->command_length() < 2) {
+ if (data->command_length() < 2)
+ {
break;
}
@@ -3560,11 +3561,9 @@ const wchar_t *reader_readline(void)
*/
if (data->buff_pos > 0)
{
- wchar_t tmp = data->command_line[data->buff_pos];
- data->command_line[data->buff_pos] = data->command_line[data->buff_pos-1];
- data->command_line[data->buff_pos-1] = tmp;
- data->buff_pos++;
- reader_repaint();
+ wcstring local_cmd = data->command_line;
+ std::swap(local_cmd.at(data->buff_pos), local_cmd.at(data->buff_pos-1));
+ set_command_line_and_position(local_cmd, data->buff_pos + 1);
}
break;
}