Redraw when backspacing a tab

This commit is contained in:
Kevin Lange 2016-12-17 22:14:13 +09:00
parent 2feaf58958
commit 0bfe9d0872

View File

@ -376,10 +376,14 @@ int rline(char * buffer, int buf_size, rline_callbacks_t * callbacks) {
continue;
case KEY_BACKSPACE:
if (context.collected) {
int should_redraw = 0;
if (!context.offset) {
continue;
}
printf("\010 \010");
if (context.buffer[context.offset-1] == '\t') {
should_redraw = 1;
}
if (context.offset != context.collected) {
int remaining = context.collected - context.offset;
for (int i = 0; i < remaining; ++i) {
@ -396,6 +400,9 @@ int rline(char * buffer, int buf_size, rline_callbacks_t * callbacks) {
context.buffer[--context.collected] = '\0';
context.offset--;
}
if (should_redraw) {
rline_redraw_clean(&context);
}
fflush(stdout);
}
continue;