From 1484799b18a2e4f799fd2db46f57806a178689d2 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 23 Nov 2014 23:50:23 +0000 Subject: [PATCH] Console example: fixing losing text selection when using TAB completion with no match --- imgui.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index b4e183586..8737b0811 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7094,6 +7094,7 @@ struct ExampleAppConsole void TextEditCallback(ImGuiTextEditCallbackData* data) { + //AddLog("cursor: %d, selection: %d-%d", data->CursorPos, data->SelectionStart, data->SelectionEnd); switch (data->EventKey) { case ImGuiKey_Tab: @@ -7150,8 +7151,11 @@ struct ExampleAppConsole match_len++; } - data->DeleteChars(word_start - data->Buf, word_end-word_start); - data->InsertChars(data->CursorPos, candidates[0], candidates[0] + match_len); + if (match_len > 0) + { + data->DeleteChars(word_start - data->Buf, word_end-word_start); + data->InsertChars(data->CursorPos, candidates[0], candidates[0] + match_len); + } // List matches AddLog("Possible matches:\n");