assist canceling

This commit is contained in:
Mirek Fidler 2022-09-12 13:24:58 +02:00
parent ba295155a2
commit be19eef079
3 changed files with 36 additions and 6 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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: