Skip to content

Commit

Permalink
Fix for 'backspace over tab' handling in ImGuiTextEditor (see BalazsJ…
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Nov 10, 2019
1 parent 8198c83 commit e60beef
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ext/texteditor/TextEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ void TextEditor::HandleKeyboardInputs()
EnterCharacter('\n', false);
else if (!IsReadOnly() && !ctrl && !alt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Tab))) {
EnterCharacter('\t', shift);
}
}

if (!IsReadOnly() && !io.InputQueueCharacters.empty())
{
Expand Down Expand Up @@ -1871,15 +1871,16 @@ void TextEditor::Backspace()
auto& line = mLines[mState.mCursorPosition.mLine];
auto cindex = GetCharacterIndex(pos) - 1;
auto cend = cindex + 1;
while (cindex > 0 && IsUTFSequence(line[cindex].mChar))
while (cindex > 0 && IsUTFSequence(line[cindex].mChar)) {
--cindex;
}

//if (cindex > 0 && UTF8CharLength(line[cindex].mChar) > 1)
// --cindex;

u.mRemovedStart = u.mRemovedEnd = GetActualCursorCoordinates();
--u.mRemovedStart.mColumn;
--mState.mCursorPosition.mColumn;
mState.mCursorPosition.mColumn = GetCharacterColumn(mState.mCursorPosition.mLine, cindex);

while (cindex < line.size() && cend-- > cindex)
{
Expand Down

0 comments on commit e60beef

Please sign in to comment.