Consolidate input completion code in preparation for advanced completion strategies (#4639)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#include "widgets/helper/ResizingTextEdit.hpp"
|
||||
|
||||
#include "common/Common.hpp"
|
||||
#include "common/CompletionModel.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
#include "controllers/completion/TabCompletionModel.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
|
||||
#include <QMimeData>
|
||||
@@ -160,16 +160,18 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
// always expected to be TabCompletionModel
|
||||
auto *completionModel =
|
||||
static_cast<CompletionModel *>(this->completer_->model());
|
||||
dynamic_cast<TabCompletionModel *>(this->completer_->model());
|
||||
assert(completionModel != nullptr);
|
||||
|
||||
if (!this->completionInProgress_)
|
||||
{
|
||||
// First type pressing tab after modifying a message, we refresh our
|
||||
// completion model
|
||||
this->completer_->setModel(completionModel);
|
||||
completionModel->refresh(currentCompletionPrefix,
|
||||
this->isFirstWord());
|
||||
completionModel->updateResults(currentCompletionPrefix,
|
||||
this->isFirstWord());
|
||||
this->completionInProgress_ = true;
|
||||
{
|
||||
// this blocks cursor movement events from resetting tab completion
|
||||
@@ -346,9 +348,4 @@ void ResizingTextEdit::insertFromMimeData(const QMimeData *source)
|
||||
insertPlainText(source->text());
|
||||
}
|
||||
|
||||
QCompleter *ResizingTextEdit::getCompleter() const
|
||||
{
|
||||
return this->completer_;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user