]> gitweb.factorcode.org Git - factor.git/commitdiff
tools.completion: make P"~/" complete properly.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 2 Jan 2022 19:59:28 +0000 (11:59 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 2 Jan 2022 19:59:28 +0000 (11:59 -0800)
basis/tools/completion/completion.factor

index b3cf283f07ee473039ec287b70f30086ab87b66b..cf469e13ec61511afd4341d1e455bfbe4f9f7ec2 100644 (file)
@@ -121,9 +121,11 @@ PRIVATE>
 PRIVATE>
 
 : paths-matching ( str -- seq )
-    dup last-path-separator [ 1 + cut ] [ drop "" ] if swap
-    dup { [ file-exists? ] [ file-info directory? ] } 1&&
-    [ directory-paths completions ] [ 2drop { } ] if ;
+    "P\"" ?head [
+        dup last-path-separator [ 1 + cut ] [ drop "" ] if swap
+        dup { [ file-exists? ] [ file-info directory? ] } 1&&
+        [ directory-paths completions ] [ 2drop { } ] if
+    ] dip [ [ [ "P\"" prepend ] dip ] assoc-map ] when ;
 
 <PRIVATE
 
@@ -175,4 +177,11 @@ PRIVATE>
 
 : complete-color? ( tokens -- ? ) "COLOR:" complete-token? ;
 
-: complete-pathname? ( tokens -- ? ) "P\"" complete-token? ;
+<PRIVATE
+
+: complete-string? ( tokens token -- ? )
+    { [ [ harvest ?last ] [ head? ] bi* ] [ complete-token? ] } 2|| ;
+
+PRIVATE>
+
+: complete-pathname? ( tokens -- ? ) "P\"" complete-string? ;