Fix Ctrl+Backspace in the console causing a crash
In v2.2.7, !1092 (merged) added Ctrl+Backspace (and Ctrl+Delete) support to the console.
In v2.2.9, !1370 (merged) fixed the game crashing if you press Ctrl+Backspace in the console, with the caret at the very start of the console input, without a text selection.
For v2.2.14, !2354 (merged) fixed Ctrl+X in the console not deleting the selected text (but still copying the selection to the clipboard), if it was selected from right to left and includes the first character... by undoing !1370 (merged).
This merge request combines the best of both worlds, allowing Ctrl+X to always delete text while still forbidding Ctrl+Backspace from causing crashes.
The root cause of the crash was M_JumpWordReverse(..., 0)
returning -1 (when it should always return >=0), which made CON_InputDelSelection()
try to memmove
and memset
four gigabytes. M_JumpWordReverse(...)
now always returns at least zero (which means that the new && input_cur != 0
check in console.c is technically superfluous).
Additionally, this merge request also fixes the clipboard being cleared by pressing Ctrl+C or Ctrl+X if you don't have a text selection in the console, and Ctrl+Insert or Shift+Delete if don't have any text in the "Multiplayer" > "Join a Game" > "Specify Server Address" box.
TL;DR:
- Fixed Ctrl+Backspace crashing when used at the start of the console (Not worth mentioning in changelogs, as this didn't affect v2.2.13)
- Fixed Ctrl+C and Ctrl+X emptying the clipboard when you haven't selected any text