From be19eef0793e043e361b260eca98150f323a10f6 Mon Sep 17 00:00:00 2001 From: Mirek Fidler Date: Mon, 12 Sep 2022 13:24:58 +0200 Subject: [PATCH] assist canceling --- uppsrc/ide/Assist.cpp | 27 ++++++++++++++++++++++++--- uppsrc/ide/Assist.h | 10 +++++++--- uppsrc/ide/clang/todo.txt | 5 +++++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/uppsrc/ide/Assist.cpp b/uppsrc/ide/Assist.cpp index 3853ad9aa..ca6ee71f4 100644 --- a/uppsrc/ide/Assist.cpp +++ b/uppsrc/ide/Assist.cpp @@ -107,6 +107,22 @@ void AssistEditor::CloseAssist() CloseTip(); } +void AssistEditor::PostInsert(int pos, const WString& s) +{ + if(pos < assist_cursor) { + CancelAutoComplete(); + assist_cursor = -1; + } +} + +void AssistEditor::PostRemove(int pos, int size) +{ + if(pos < assist_cursor) { + CancelAutoComplete(); + assist_cursor = -1; + } +} + bool isincludefnchar(int c) { return c && c != '<' && c != '>' && c != '?' && @@ -247,7 +263,7 @@ void AssistEditor::SyncAssist() const AssistItem& m = assist_item[i]; if(!found[i] && (typei < 0 || m.typei == typei) && - (pass ? m.uname.StartsWith(uname) : m.name.StartsWith(name))) { + ((pass ? m.uname.StartsWith(uname) : m.name.StartsWith(name)) || m.kind == KIND_ERROR)) { found[i] = true; assist_item_ndx.Add(i); } @@ -447,7 +463,6 @@ void AssistEditor::Assist(bool macros) LTIMING("Assist"); CloseAssist(); int q = GetCursor32(); - assist_cursor = q; assist_type.Clear(); assist_item.Clear(); include_assist = false; @@ -455,7 +470,8 @@ void AssistEditor::Assist(bool macros) return; int pos = GetCursor(); - ReadIdBackPos(pos, false); // libclang does not work well if file is not truncated for autocomplete + ReadIdBackPos(pos, false); // libclang does not work well if file is not truncated for autocomplete (?) + assist_cursor = pos; CurrentFileContext cfx = CurrentContext(pos); int line = GetLinePos(pos); if(cfx.content.GetCount()) @@ -484,6 +500,11 @@ bool AssistEditor::WheelHook(Ctrl *, bool inframe, int event, Point p, int zdelt void AssistEditor::PopUpAssist(bool auto_insert) { LTIMING("PopUpAssist"); + int pos = GetCursor(); + ReadIdBackPos(pos, false); + if(pos != assist_cursor) + return; + if(assist_item.GetCount() == 0) { AssistItem& m = assist_item.Add(); m.kind = KIND_ERROR; diff --git a/uppsrc/ide/Assist.h b/uppsrc/ide/Assist.h index 30e3d31d4..f57d60c2a 100644 --- a/uppsrc/ide/Assist.h +++ b/uppsrc/ide/Assist.h @@ -65,6 +65,8 @@ struct AssistEditor : CodeEditor, Navigator { virtual void SelectionChanged(); virtual void DirtyFrom(int line); virtual void State(int reason); + virtual void PostInsert(int pos, const WString& s); + virtual void PostRemove(int pos, int size); virtual int GetCurrentLine(); @@ -107,9 +109,11 @@ struct AssistEditor : CodeEditor, Navigator { bool auto_assist; bool commentdp; bool include_assist; - WString cachedline; - int cachedpos; - int cachedln; + + WString cachedline; // for Ch method + int cachedpos; // for Ch method + int cachedln; // for Ch method + bool include_local; int include_back; String include_path; diff --git a/uppsrc/ide/clang/todo.txt b/uppsrc/ide/clang/todo.txt index 48e31d324..43e4cf349 100644 --- a/uppsrc/ide/clang/todo.txt +++ b/uppsrc/ide/clang/todo.txt @@ -11,7 +11,11 @@ EPICS: = Assist configuration - Option "first config only" - Option "reindex manual" (autosetup based on CPU cores) +- Number of indexer threads +- Number of cached files - options to disable assist +- option for logging +- in linux, show libclang path = Annotations/Visitor/formatting @@ -77,6 +81,7 @@ ISUES: - Core/Parser.h slow for some reason... +- AssistEditor Virtual methods not showing LineEdit etc.. NONCLANG: