Suggestions for cd and paths, and a directory history; bjoterm 0.1.2
The editor suggests, as fish does, the newest cd line of the history whose directory exists, else the directories or files that start with the word. prevd, nextd and cdh move in the directory history, and so do Alt-Left and Alt-Right on an empty line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
77c6d7977a
commit
5012a5d993
8 changed files with 262 additions and 14 deletions
|
|
@ -52,6 +52,24 @@
|
|||
(any? (fun (c) (= c "jobs ")) (record-ref (complete "jo") candidates)) #t)
|
||||
(expect "a first word with a / completes files" (record-ref (complete "./ab") candidates)
|
||||
["./abc.txt " "./abd/"])
|
||||
|
||||
;; Suggestions.
|
||||
(ignore (directory-create (path-combine dir "abd/deeper")))
|
||||
(ignore (directory-create (path-combine dir "other")))
|
||||
(expect "cd suggests the only directory" (suggest "cd ot" []) (Some "her/"))
|
||||
(expect "and not files" (suggest "cd abc" []) None)
|
||||
(expect "the common prefix of several" (suggest "cd abd/" []) (Some "deeper/"))
|
||||
(expect "a path argument suggests files, with no space" (suggest "cat abc" []) (Some ".txt"))
|
||||
(expect "several files, their common prefix" (suggest "cat a" []) None)
|
||||
(expect "in a directory" (suggest "cat abd/in" []) (Some "ner"))
|
||||
(expect "not the command" (suggest "ab" []) None)
|
||||
(expect "not an empty argument" (suggest "cat " []) None)
|
||||
(expect "not a second line" (suggest "echo 'a\ncat abc" []) None)
|
||||
(expect "cd from the history, newest first"
|
||||
(suggest "cd a" ["cd abd" "cd abd/deeper" "ls"]) (Some "bd/deeper"))
|
||||
(expect "not a directory that is gone"
|
||||
(suggest "cd o" ["cd other" "cd old-gone"]) (Some "ther"))
|
||||
(expect "only cd lines" (suggest "cd o" ["cdx other"]) (Some "ther/"))
|
||||
(set-current-directory! here)
|
||||
(ignore (directory-delete-tree dir))
|
||||
0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue