mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-19 04:26:52 -04: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
@ -113,22 +113,22 @@ namespace ClassicalSharp.Gui {
|
||||
Dispose();
|
||||
Init();
|
||||
} else if( !buffer.Empty && caretPos != 0 ) {
|
||||
if( !BackspaceColourCode())
|
||||
DeleteChar();
|
||||
BackspaceColourCode();
|
||||
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…
x
Reference in New Issue
Block a user