sled

Једноставни уређивач текста
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување aae1c67f43cedf35db9da105554d9212188fb6f6
родитељ 76daa021961b429e627dfc5c6755f2d7d8f6a66f
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Sat, 14 May 2022 21:10:08 +0200

Fix: instance of WRAP_WIDTH (display length) being assigned to coord.col (buffer length)

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
MTODO | 6+++---
Msled.c | 11+++++------
измењених датотека: 2, додавања: 8(+), брисања: 9(-)

diff --git a/TODO b/TODO @@ -1,12 +1,12 @@ TODO ==== + [ ] Replace (patch) + [x] Change status line X position to track display (real) coordinates instead of buffer index - [ ] Bug: investigate dotfiles/README.md table editing - - [ ] Replace (patch) + [x] Bug: investigate dotfiles/README.md table editing [~] Code optimization (struct coord...) diff --git a/sled.c b/sled.c @@ -418,7 +418,8 @@ insert_char(struct DrawState* state, uint32_t ch) { int saved_column = state->coord.col; buffer_line = state->buffer + state->coord.row; - state->coord.col = WRAP_WIDTH; + state->coord.col + = buffer_length(state, buffer_line->text, WRAP_WIDTH); while (state->coord.col > 0 && !u32_is_word_boundary(buffer_line->text[state->coord.col - 1], @@ -1276,10 +1277,9 @@ insert_line(struct DrawState* state) while (state->display_column >= WRAP_WIDTH) { int saved_column = state->coord.col; - int distance_to_eol; buffer_line = state->buffer + state->coord.row; - distance_to_eol = buffer_line->length - saved_column; - state->coord.col = WRAP_WIDTH + 1; + state->coord.col + = buffer_length(state, buffer_line->text, WRAP_WIDTH); while (state->coord.col > 0 && !u32_is_word_boundary(buffer_line->text[state->coord.col - 1], @@ -1293,8 +1293,7 @@ insert_line(struct DrawState* state) simple_insert_line(state); state->saved_column = -1; position_to(state, state->coord.row + 1, - state->buffer[state->coord.row + 1].length - - distance_to_eol); + saved_column - state->coord.col); } #endif /* ENABLE_WRAP */ simple_insert_line(state);