fix: Invalid/Dangling completion after updating input (#4072)
This commit is contained in:
@@ -24,6 +24,11 @@ public:
|
||||
|
||||
void setCompleter(QCompleter *c);
|
||||
QCompleter *getCompleter() const;
|
||||
/**
|
||||
* Resets a completion for this text if one was is progress.
|
||||
* See `completionInProgress_`.
|
||||
*/
|
||||
void resetCompletion();
|
||||
|
||||
protected:
|
||||
int heightForWidth(int) const override;
|
||||
@@ -41,6 +46,24 @@ private:
|
||||
QString textUnderCursor(bool *hadSpace = nullptr) const;
|
||||
|
||||
QCompleter *completer_ = nullptr;
|
||||
/**
|
||||
* This is true if a completion was done but the user didn't type yet,
|
||||
* and might want to press `Tab` again to get the next completion
|
||||
* on the original text.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* input: "pog"
|
||||
* `Tab` pressed:
|
||||
* - complete to "PogBones"
|
||||
* - retain "pog" for next completion
|
||||
* - set `completionInProgress_ = true`
|
||||
* `Tab` pressed again:
|
||||
* - complete ["pog"] to "PogChamp"
|
||||
*
|
||||
* [other key] pressed - updating the input text:
|
||||
* - set `completionInProgress_ = false`
|
||||
*/
|
||||
bool completionInProgress_ = false;
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
|
||||
Reference in New Issue
Block a user