]> gitweb.factorcode.org Git - factor.git/commitdiff
tools.completion: fix CHAR: and COLOR: completion to require extra tokens.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 23 Oct 2012 01:29:53 +0000 (18:29 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 23 Oct 2012 01:29:53 +0000 (18:29 -0700)
basis/tools/completion/completion-tests.factor
basis/tools/completion/completion.factor

index 05c8e321ecf8c55c11ea2079db4dae158113d57d..e35fdb9d0494f45dfe06aa0dfd84fed30f4ce25a 100644 (file)
@@ -30,3 +30,6 @@ IN: tools.completion
 { f } [ { "USING:" "A" "B" "C" ";" } complete-vocab? ] unit-test
 { t } [ { "X" ";" "USING:" "A" "B" "C" } complete-vocab? ] unit-test
 
+{ f } [ { "CHAR:" } complete-CHAR:? ] unit-test
+{ t } [ { "CHAR:" "" } complete-CHAR:? ] unit-test
+{ t } [ { "CHAR:" "a" } complete-CHAR:? ] unit-test
index 8c61da927b23d9a80265cb1b9c393c22e9fccb1f..22fec129b044a078e26b2f6a4e209e40ecdda8a7 100644 (file)
@@ -135,8 +135,18 @@ PRIVATE>
 : complete-vocab? ( tokens -- ? )
     { [ complete-single-vocab? ] [ complete-vocab-list? ] } 1|| ;
 
-: complete-CHAR:? ( tokens -- ? )
-    2 short tail* "CHAR:" swap member? ;
+<PRIVATE
+
+: complete-token? ( tokens token -- ? )
+    over last empty? [
+        [ harvest ?last ] [ = ] bi*
+    ] [
+        swap harvest dup length 1 >
+        [ 2 tail* ?first = ] [ 2drop f ] if
+    ] if ;
+
+PRIVATE>
+
+: complete-CHAR:? ( tokens -- ? ) "CHAR:" complete-token? ;
 
-: complete-COLOR:? ( tokens -- ? )
-    2 short tail* "COLOR:" swap member? ;
+: complete-COLOR:? ( tokens -- ? ) "COLOR:" complete-token? ;