чување e09d66db63aa9ae14723664627a2606bbc51de85
родитељ 50ea3360bfc4a30302b65f21de99507106907eb6
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Mon, 6 Mar 2023 22:26:19 +0100
Bugfix: Moving to the left when at column 0 should not wrap to end of line
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 2, додавања: 10(+), брисања: 4(-)
diff --git a/TODO b/TODO
@@ -1,7 +1,7 @@
TODO
====
- [ ] Moving to the left of the first char in buffer should not wrap
+ [x] Moving to the left of the first char in buffer should not wrap
around to the last char in that line
[ ] "Replace text" dialog (patch)
diff --git a/sled.c b/sled.c
@@ -632,7 +632,10 @@ position_to(struct DrawState* state, const int row, const int column)
state->coord.col = buffer_length(state,
state->buffer[state->coord.row].text,
state->saved_column);
- if (state->coord.col > state->buffer[state->coord.row].length)
+ if (state->coord.col < 0)
+ state->coord.col = 0;
+ else if (state->coord.col
+ > (int)state->buffer[state->coord.row].length)
state->coord.col
= state->buffer[state->coord.row].length;
dlen = display_length(state,
@@ -645,7 +648,10 @@ position_to(struct DrawState* state, const int row, const int column)
else
{
state->coord.col = column;
- if (state->coord.col > state->buffer[state->coord.row].length)
+ if (state->coord.col < 0)
+ state->coord.col = 0;
+ else if (state->coord.col
+ > (int)state->buffer[state->coord.row].length)
state->coord.col
= state->buffer[state->coord.row].length;
state->display_column = display_length(state,
@@ -2085,7 +2091,7 @@ main(int argc, char** argv)
#ifdef CREATE_BACKUPS
#ifdef BACKUP_FAIL_OK
state.backup_possible = dir_access != -1;
-#else /* !BACKUP_FAIL_OK */
+#else /* !BACKUP_FAIL_OK */
if (dir_access == -1)
{
errno = dir_access_errno;