(core) For autocomplete suggestions in formulas, add links to suggestions we have documentation for.

Summary:
This is a hacky solution that unfortunately relies on internal workings of ACE
autocomplete popups. I don't see a less hacky one if we stick with ACE
autocomplete.

Test Plan: Added a test case for links to test/nbrowser/Formulas.ts

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D2610
This commit is contained in:
Dmitry S 2020-09-13 01:41:43 -04:00
parent 45d2d5f897
commit 9d6637458e
2 changed files with 7 additions and 0 deletions

View File

@ -78,6 +78,8 @@ class AutocompleteContext(object):
if completion: if completion:
# For methods (eg ".lookupOne"), use the original result as funcname (eg "Foo.lookupOne"). # For methods (eg ".lookupOne"), use the original result as funcname (eg "Foo.lookupOne").
if dot >= 0: if dot >= 0:
varname = funcname[:dot]
funcname = self._lowercase.get(varname, varname) + key
completion = completion._replace(funcname=funcname) completion = completion._replace(funcname=funcname)
return tuple(completion) return tuple(completion)

View File

@ -111,6 +111,11 @@ class TestCompletion(test_engine.EngineTestCase):
('Address.lookupRecords', '(colName=<value>, ...)', True), ('Address.lookupRecords', '(colName=<value>, ...)', True),
]) ])
self.assertEqual(self.engine.autocomplete("address.look", "Students"), [
('Address.lookupOne', '(colName=<value>, ...)', True),
('Address.lookupRecords', '(colName=<value>, ...)', True),
])
def test_suggest_column_type_methods(self): def test_suggest_column_type_methods(self):
# Should treat columns as correct types. # Should treat columns as correct types.
self.assertGreaterEqual(set(self.engine.autocomplete("$firstName.", "Students")), self.assertGreaterEqual(set(self.engine.autocomplete("$firstName.", "Students")),