(core) Add 'value' to trigger formula autocomplete

Summary:
API signature for autocomplete updated to add column ID, which is
necessary for exposing correct types for 'value'.

Test Plan: Unit tests.

Reviewers: alexmojaki

Reviewed By: alexmojaki

Subscribers: jarek, alexmojaki

Differential Revision: https://phab.getgrist.com/D2896
This commit is contained in:
George Gevoian
2021-07-07 09:03:01 -07:00
parent 8524b4f791
commit 9592e3610b
9 changed files with 105 additions and 54 deletions

View File

@@ -1281,7 +1281,7 @@ class Engine(object):
if not self._compute_stack:
self._bring_lookups_up_to_date(doc_action)
def autocomplete(self, txt, table_id):
def autocomplete(self, txt, table_id, column_id):
"""
Return a list of suggested completions of the python fragment supplied.
"""
@@ -1295,6 +1295,13 @@ class Engine(object):
context = self._autocomplete_context.get_context()
context['rec'] = table.sample_record
# Remove values from the context that need to be recomputed.
context.pop('value', None)
column = table.get_column(column_id) if table.has_column(column_id) else None
if column and not column.is_formula():
context['value'] = column.sample_value()
completer = rlcompleter.Completer(context)
results = []
at = 0