mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-24 01:52:24 -05:00
Fix crashing when you type in %8, then press left, then press backspace. (Thanks 123DMWM)
This commit is contained in:
parent
1ea806a38f
commit
aebeefc1ed
1 changed files with 9 additions and 9 deletions
|
@ -37,8 +37,8 @@ namespace ClassicalSharp.Gui {
|
|||
else if( key == Key.End ) EndKey();
|
||||
else if( game.Network.ServerSupportsFullCP437 &&
|
||||
key == game.InputHandler.Keys[KeyBinding.ExtendedInput] )
|
||||
altText.SetActive( !altText.Active );
|
||||
else if( clipboardDown && !OtherKey( key ) ) return false;
|
||||
altText.SetActive( !altText.Active );
|
||||
else if( clipboardDown && !OtherKey( key ) ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -113,22 +113,22 @@ namespace ClassicalSharp.Gui {
|
|||
Dispose();
|
||||
Init();
|
||||
} else if( !buffer.Empty && caretPos != 0 ) {
|
||||
DeleteChar();
|
||||
BackspaceColourCode();
|
||||
if( !BackspaceColourCode())
|
||||
DeleteChar();
|
||||
Dispose();
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
void BackspaceColourCode() {
|
||||
bool BackspaceColourCode() {
|
||||
// If text is XYZ%eH, backspaces to XYZ.
|
||||
int index = caretPos == -1 ? buffer.Length - 1 : caretPos;
|
||||
if( index <= 0 ) return;
|
||||
if( index <= 1 ) return false;
|
||||
|
||||
if( index == 0 || buffer.value[index - 1] != '%'
|
||||
|| !game.Drawer2D.ValidColour( buffer.value[index] ) )
|
||||
return;
|
||||
if( buffer.value[index - 1] != '%' || !game.Drawer2D.ValidColour( buffer.value[index] ) )
|
||||
return false;
|
||||
DeleteChar(); DeleteChar();
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeleteChar() {
|
||||
|
|
Loading…
Add table
Reference in a new issue