[rkward/work/consolecompletion] /: Hide completion offers, when completion was executed

Thomas Friedrichsmeier null at kde.org
Mon Jan 27 20:13:44 GMT 2020


Git commit e766625455e34b782182e4efe9c7dab232b74000 by Thomas Friedrichsmeier.
Committed on 27/01/2020 at 20:13.
Pushed by tfry into branch 'work/consolecompletion'.

Hide completion offers, when completion was executed

M  +1    -0    ChangeLog
M  +17   -1    rkward/windows/rkcodecompletion.cpp
M  +3    -0    rkward/windows/rkcodecompletion.h

https://commits.kde.org/rkward/e766625455e34b782182e4efe9c7dab232b74000

diff --git a/ChangeLog b/ChangeLog
index 13663579..c67f02bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
 --- Version 0.7.2 - UNRELEASED
+- Hide code completion offers, when a completion was executed
 * TODO: Bring new code hinting features to the console window!
 - On unix-systems, RKWard can now be run without installation
 - Kate addons are now supported within RKWard. Intially, search-in-files, snippets, and projects are loaded by default
diff --git a/rkward/windows/rkcodecompletion.cpp b/rkward/windows/rkcodecompletion.cpp
index 837a0e10..3a4bf6b1 100644
--- a/rkward/windows/rkcodecompletion.cpp
+++ b/rkward/windows/rkcodecompletion.cpp
@@ -426,6 +426,12 @@ bool RKCompletionManager::eventFilter (QObject*, QEvent* event) {
 	return false;
 }
 
+void RKCompletionManager::stopCompletion () {
+	RK_TRACE (COMMANDEDITOR);
+	cc_iface->abortCompletion ();
+	completion_timer->stop ();
+}
+
 //////////////////////// RKCompletionModelBase ////////////////////
 
 RKCompletionModelBase::RKCompletionModelBase (RKCompletionManager *manager) : KTextEditor::CodeCompletionModel (manager) {
@@ -460,6 +466,16 @@ int RKCompletionModelBase::rowCount (const QModelIndex& parent) const {
 	return 0;  // no children on completion entries
 }
 
+void RKCompletionModelBase::executeCompletionItem (KTextEditor::View* view, const KTextEditor::Range& word, const QModelIndex& index) const {
+	RK_TRACE (COMMANDEDITOR);
+
+	// When a completion gets executed, stop the completion. Unfortunately, this does not happen automatically for us, because
+	// a) we have to invoke completion "manually", and b) we don't want to hide completions, whenever there is *any* exact match.
+	KTextEditor::CodeCompletionModel::executeCompletionItem (view, word, index);
+	manager->stopCompletion ();
+}
+
+
 //////////////////////// RKCodeCompletionModel ////////////////////
 
 RKCodeCompletionModel::RKCodeCompletionModel (RKCompletionManager *manager) : RKCompletionModelBase (manager) {
@@ -533,7 +549,7 @@ QVariant RKCodeCompletionModel::data (const QModelIndex& index, int role) const
 
 QString findCommonCompletion (const QStringList &list, const QString &lead, bool *exact_match) {
 	RK_TRACE (COMMANDEDITOR);
-	RK_DEBUG(COMMANDEDITOR, DL_DEBUG, "Looking for commong completion among set of %d, starting with %s", list.size (), qPrintable (lead));
+	RK_DEBUG(COMMANDEDITOR, DL_DEBUG, "Looking for common completion among set of %d, starting with %s", list.size (), qPrintable (lead));
 
 	*exact_match = true;
 	QString ret;
diff --git a/rkward/windows/rkcodecompletion.h b/rkward/windows/rkcodecompletion.h
index 131480bf..3ce51c66 100644
--- a/rkward/windows/rkcodecompletion.h
+++ b/rkward/windows/rkcodecompletion.h
@@ -49,6 +49,8 @@ public:
 	KTextEditor::Range currentArgnameRange () const { return argname_range; };
 	KTextEditor::Range currentCallRange () const;
 	KTextEditor::View* view () const { return (_view); };
+
+	void stopCompletion ();
 public slots:
 	void userTriggeredCompletion ();
 private slots:
@@ -98,6 +100,7 @@ public:
 	QString filterString (KTextEditor::View *, const KTextEditor::Range &, const KTextEditor::Cursor &) override { return QString (); };
 	bool shouldAbortCompletion (KTextEditor::View *, const KTextEditor::Range &, const QString &) override { return false; }
 	KTextEditor::CodeCompletionModelControllerInterface::MatchReaction matchingItem (const QModelIndex &) override { return KTextEditor::CodeCompletionModelControllerInterface::None; };
+	void executeCompletionItem (KTextEditor::View *view, const KTextEditor::Range &word, const QModelIndex &index) const override;
 
 	int rowCount (const QModelIndex &parent) const override;
 	QModelIndex index (int row, int column, const QModelIndex &parent = QModelIndex ()) const override;



More information about the rkward-tracker mailing list