[gnome-calculator] Fixed variable autocompletion
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator] Fixed variable autocompletion
- Date: Tue, 30 Nov 2021 00:17:58 +0000 (UTC)
commit 660c903bec807b33771400e68ed84f4e61bc47c6
Author: Robert Roth <robert roth off gmail com>
Date: Tue Nov 30 02:17:46 2021 +0200
Fixed variable autocompletion
lib/math-variables.vala | 2 +-
src/math-display.vala | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/lib/math-variables.vala b/lib/math-variables.vala
index 9685b2c4..4562561d 100644
--- a/lib/math-variables.vala
+++ b/lib/math-variables.vala
@@ -125,7 +125,7 @@ public class MathVariables : Object
public string[] variables_eligible_for_autocompletion (string text)
{
string[] eligible_variables = {};
- if (text.length <=1)
+ if (text.length < 1)
return eligible_variables;
string[] variables = get_names ();
diff --git a/src/math-display.vala b/src/math-display.vala
index 342c1836..82a65464 100644
--- a/src/math-display.vala
+++ b/src/math-display.vala
@@ -652,6 +652,8 @@ public class VariableCompletionProvider : CompletionProvider, GtkSource.Completi
return _("Defined Variables");
}
+ public override int get_priority (GtkSource.CompletionContext context) { return 1; }
+
public static string[] get_matches_for_completion_at_cursor (GtkSource.CompletionContext context,
MathVariables variables)
{
Gtk.TextIter start_iter, end_iter;
@@ -668,6 +670,7 @@ public class VariableCompletionProvider : CompletionProvider, GtkSource.Completi
{
ListStore proposals = new ListStore (typeof (CompletionProposal));
string[] variables = get_matches_for_completion_at_cursor (context, _equation.variables);
+ string word = context.get_word ();
if (variables.length > 0)
{
@@ -681,6 +684,6 @@ public class VariableCompletionProvider : CompletionProvider, GtkSource.Completi
}
}
- return proposals;
+ return new Gtk.FilterListModel (proposals, create_filter (word));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]