Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/slash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,8 @@ static void slash_delete(struct slash *slash)
if (slash->cursor < slash->length) {
slash->length--;
memmove(&slash->buffer[slash->cursor],
&slash->buffer[slash->cursor + 1], slash->length - slash->cursor);
&slash->buffer[slash->cursor + 1],
slash->length - slash->cursor);
slash->buffer[slash->length] = '\0';
}
}
Expand All @@ -1025,24 +1026,26 @@ static void slash_backspace(struct slash *slash)
slash->cursor--;
slash->length--;
memmove(&slash->buffer[slash->cursor],
&slash->buffer[slash->cursor + 1], slash->length - slash->cursor);
&slash->buffer[slash->cursor + 1],
slash->length - slash->cursor);
slash->buffer[slash->length] = '\0';
}
}

static void slash_delete_word(struct slash *slash)
{
int old_cursor = slash->cursor, erased;
size_t old_cursor = slash->cursor;

while (slash->cursor > 0 && slash->buffer[slash->cursor-1] == ' ')
slash->cursor--;
while (slash->cursor > 0 && slash->buffer[slash->cursor-1] != ' ')
slash->cursor--;

erased = old_cursor - slash->cursor;

memmove(slash->buffer + slash->cursor, slash->buffer + old_cursor, erased);
slash->length -= erased;
slash->length -= old_cursor - slash->cursor;
memmove(&slash->buffer[slash->cursor],
&slash->buffer[old_cursor],
slash->length - slash->cursor);
slash->buffer[slash->length] = '\0';
}

static void slash_swap(struct slash *slash)
Expand Down