]> gitweb.factorcode.org Git - factor.git/commitdiff
tools.completion: support qualified word completions.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 22 Sep 2020 18:12:52 +0000 (11:12 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 22 Sep 2020 18:12:52 +0000 (11:12 -0700)
basis/tools/completion/completion.factor

index 09c89d181633ab41af653e771aa3bb030642e609..648d827b7a2cf3635c156f645a346a7cc4e16708 100644 (file)
@@ -78,15 +78,23 @@ PRIVATE>
 : name-completions ( str seq -- seq' )
     [ dup name>> ] { } map>assoc completions ;
 
+: vocab-words-matching ( str vocab -- seq )
+    vocab-words name-completions ;
+
+: qualified-matching ( str -- seq/f )
+    ":" split1 [
+        swap
+        [ vocab-words-matching ]
+        [ ":" append [ prepend ] curry assoc-map ] bi
+    ] [ drop f ] if* ;
+
 : words-matching ( str -- seq )
-    all-words name-completions ;
+    [ all-words name-completions ]
+    [ qualified-matching [ prepend ] unless-empty ] bi ;
 
 : vocabs-matching ( str -- seq )
     all-disk-vocabs-recursive filter-vocabs name-completions ;
 
-: vocab-words-matching ( str vocab -- seq )
-    vocab-words name-completions ;
-
 : chars-matching ( str -- seq )
     name-map keys dup zip completions ;