чување afb31809543844044d6681a962ac657e8cfd0baa
родитељ eab228615dae5077fddf4d1c505379acad1a8abe
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Wed, 21 Jul 2021 07:59:46 +0200
Fix: insert_* functions had the starting index off by one, resulting in an incorrect shift of the ending part of the string
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 2, додавања: 4(+), брисања: 4(-)
diff --git a/TODO b/TODO
@@ -1,7 +1,7 @@
TODO
====
- [ ] Fix: pressing C-R, then C-W twice and typing
+ [x] Fix: pressing C-R, then C-W twice and typing
[x] Line editing with cursor
<x> Previous/next word?
diff --git a/poe.c b/poe.c
@@ -584,7 +584,7 @@ insert_search_char(struct DrawState* state, uint32_t ch)
size_t len = u32_strlen(state->search);
if (state->search_column < MAXSEARCH-1)
{
- size_t i = len;
+ size_t i = len+1;
int add_null = state->search[state->search_column] == 0;
while (i < MAXSEARCH-2 && i > state->search_column)
{
@@ -1378,7 +1378,7 @@ erase_prev_word(struct DrawState* state)
for (int j = i; j < len-d; j++)
pline[j] = pline[j+d];
- len -= state->input_column-i;
+ len -= d;
state->input_buffer[state->input_row].length = len;
pline[len] = 0;
state->input_column = i;
@@ -1545,7 +1545,7 @@ insert_char(struct DrawState* state, uint32_t ch)
size_t len = buffer_line->length;
if (state->input_column < MAXBUFLINE-1)
{
- size_t i = len;
+ size_t i = len+1;
int add_null = buffer_line->text[state->input_column] == 0;
while (i < MAXBUFLINE-2 && i > state->input_column)
{