fix: fixes Issue #1621 (#2189)

fixes Issue #1621.
Using shift-tab on an empty line caused a crash.  Additionally, changed
the hard coded value of 4 to the tab size variable it really needs to be.
This commit is contained in:
paxcut
2025-04-23 06:54:39 -07:00
committed by GitHub
parent 02cadc264e
commit 60c1c22a73

View File

@@ -1479,8 +1479,8 @@ void TextEditor::EnterCharacter(ImWchar aChar, bool aShift) {
SetCursorPosition(Coordinates(coord.mLine, GetCharacterColumn(coord.mLine, cindex + spacesToInsert)));
} else {
auto spacesToRemove = (cindex % mTabSize);
if (spacesToRemove == 0) spacesToRemove = 4;
if (spacesToRemove == 0) spacesToRemove = mTabSize;
spacesToRemove = std::min(spacesToRemove, (int32_t) line.size());
for (int j = 0; j < spacesToRemove; j++) {
if ((line.begin() + cindex - 1)->mChar == ' ') {
line.erase(line.begin() + cindex - 1);