Fix console crash and console key input#1880
Fix console crash and console key input#1880VReaperV wants to merge 2 commits intoDaemonEngine:masterfrom
Conversation
d7aff97 to
745136e
Compare
| return Key::NONE; | ||
| } | ||
|
|
||
| std::string KeyToStringUnprefixed( Key key ) { |
There was a problem hiding this comment.
I don't understand, what is the point of forming a string with words like ESCAPE, 0x63 etc.?
| * in a separate execution of IN_ProcessEvents() | ||
| * The key character can also be anywhere in the text | ||
| * This might be an SDL bug */ | ||
| text.erase( |
There was a problem hiding this comment.
This would break the feature where you can hold ALT to type a character that would otherwise be a console key (works on some Linux environments)
There was a problem hiding this comment.
Isn't that handled in SDL_EVENT_KEY_DOWN()?
There was a problem hiding this comment.
That is where the ALT exemption is initially applied. But IIUC this new third level of console key filtering has no condition to check that, so such characters would be filtered out.
| int argNum = args.Argc() - 1; | ||
| std::string prefix; | ||
| if (!args.Argc() || Str::cisspace(GetText()[GetCursorPos() - 1])) { | ||
| if (!args.Argc() || !GetCursorPos() || Str::cisspace(GetText()[GetCursorPos() - 1])) { |
There was a problem hiding this comment.
The way things initially go wrong is with the subtraction underflow in std::string commandText = Str::UTF32To8(GetText().substr(1, GetCursorPos() - 1));. Would be nicer to return before that
|
For future reference, the Windows 11 keyboard layout where the console key issue always happens is "United Kingdom Extended" which has a ` dead key. There are other layouts which have an (Right)Alt + ` dead key combination; alt-tabbing in those could lead to accidentally triggering the dead key (and hence the bug) if pressing the console key while Alt is still held. I guess this never happens to me only because I always use left Alt for alt-tabbing. Filtering out the console key itself won't get all possible cases of junk caused by dead keys. For example if a ` dead key is queued up when you open the console and then the first letter you type is |
tab)