Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix last keystroke time not being updated on certain keys #76

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mjkloeckner
Copy link
Contributor

I noticed that while pressing tab the cursor last keystroke was not being updated:

case SDLK_TAB: {
    for (size_t i = 0; i < 4; ++i) {
        editor_insert_char(&editor, ' ');
    }
}

it should be:

case SDLK_TAB: {
    for (size_t i = 0; i < 4; ++i) {
        editor_insert_char(&editor, ' ');
    }
    editor.last_stroke = SDL_GetTicks();
}

but instead of updating the last keystroke individually in every key press, it's better to update it when a key is pressed regardless if the key being pressed has a dedicated function or not.

This commit removes all the editor.last_stroke = SDL_GetTicks(); from every key case and adds only one after the switch execution.

I noticed that while pressing tab the cursor last keystroke was not
being updated:

```c
for (size_t i = 0; i < 4; ++i) {
    editor_insert_char(&editor, ' ');
}
```

it should be:

```c
for (size_t i = 0; i < 4; ++i) {
    editor_insert_char(&editor, ' ');
}
editor.last_stroke = SDL_GetTicks();
```

but instead of updating the last keystroke individualy in every
keypress, it's better to update it when a key is pressed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant