Skip to content

Commit

Permalink
fixed bug caused by interactions with CTRL-E and CTRL-W
Browse files Browse the repository at this point in the history
  • Loading branch information
ajccosta committed Oct 12, 2023
1 parent 9098fc8 commit 2f62afe
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ static void get_input(char* in) {
case 5:
//CTRL-E
pos = len;
browsing = searched = 1;
browsing = 0;
searched = 1;
break;

case 4:
Expand All @@ -457,15 +458,15 @@ static void get_input(char* in) {
//CTRL-Backspace
case 23:
//CTRL-W
while(in[pos] != ' ' && pos != 0) { //Delete last typed word
pos--; len--; inp = '\0'; //Delete 1 character
inp = '\0';
while(in[pos-1] == ' ' && pos > 1) { //Delete trailing spaces
pos--; len--; //Delete 1 character
}

while(in[pos-1] == ' ' && pos >= 1) { //Delete trailing spaces
pos--; len--; inp = '\0'; //Delete 1 character
while(in[pos] != ' ' && pos > 0) { //Delete last typed word
pos--; len--;
}

//printf("len: %d", len);
in[pos] = '\0';

break;

case 27:
Expand Down

0 comments on commit 2f62afe

Please sign in to comment.