mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 02:25:39 +03:00
fix a few things, but oops completion is broken somehow
This commit is contained in:
parent
64757efa3e
commit
ed881583e7
@ -21,7 +21,6 @@ module Unison.CommandLine.Completion
|
||||
where
|
||||
|
||||
import Control.Lens (ifoldMap)
|
||||
import Control.Lens qualified as Lens
|
||||
import Control.Lens.Cons (unsnoc)
|
||||
import Data.Aeson qualified as Aeson
|
||||
import Data.List (isPrefixOf)
|
||||
@ -52,7 +51,7 @@ import Unison.Codebase.SqliteCodebase.Conversions qualified as Cv
|
||||
import Unison.CommandLine.InputPattern qualified as IP
|
||||
import Unison.HashQualified' qualified as HQ'
|
||||
import Unison.Name qualified as Name
|
||||
import Unison.NameSegment (NameSegment)
|
||||
import Unison.NameSegment (NameSegment (..))
|
||||
import Unison.Prelude
|
||||
import Unison.Server.Local.Endpoints.NamespaceListing (NamespaceListing (NamespaceListing))
|
||||
import Unison.Server.Local.Endpoints.NamespaceListing qualified as Server
|
||||
@ -149,7 +148,8 @@ completeWithinNamespace compTypes query currentPath = do
|
||||
currentBranchSuggestions <- do
|
||||
nib <- namesInBranch shortHashLen b
|
||||
nib
|
||||
& fmap (\(isFinished, match) -> (isFinished, Text.unpack . Path.toText' $ queryPathPrefix Lens.:> NameSegment.unsafeParseText match))
|
||||
-- See Note [Naughty NameSegment]
|
||||
& fmap (\(isFinished, match) -> (isFinished, Text.unpack (Path.toText' queryPathPrefix <> "." <> match)))
|
||||
& filter (\(_isFinished, match) -> List.isPrefixOf query match)
|
||||
& fmap (\(isFinished, match) -> prettyCompletionWithQueryPrefix isFinished query match)
|
||||
& pure
|
||||
@ -179,9 +179,8 @@ completeWithinNamespace compTypes query currentPath = do
|
||||
childBranch <- V2Causal.value childCausal
|
||||
nib <- namesInBranch shortHashLen childBranch
|
||||
nib
|
||||
& fmap
|
||||
( \(isFinished, match) -> (isFinished, Text.unpack . Path.toText' $ queryPathPrefix Lens.:> suffix Lens.:> NameSegment.unsafeParseText match)
|
||||
)
|
||||
-- See Note [Naughty NameSegment]
|
||||
& fmap (\(isFinished, match) -> (isFinished, Text.unpack (Path.toText' queryPathPrefix <> "." <> match)))
|
||||
& filter (\(_isFinished, match) -> List.isPrefixOf query match)
|
||||
& fmap (\(isFinished, match) -> prettyCompletionWithQueryPrefix isFinished query match)
|
||||
& pure
|
||||
|
@ -5,11 +5,11 @@ Tests that functions named `.` are rendered correctly.
|
||||
```
|
||||
|
||||
``` unison
|
||||
(.) f g x = f (g x)
|
||||
(`.`) f g x = f (g x)
|
||||
|
||||
use Boolean not
|
||||
|
||||
noop = not . not
|
||||
noop = not `.` not
|
||||
```
|
||||
|
||||
``` ucm
|
||||
|
@ -1,11 +1,11 @@
|
||||
Tests that functions named `.` are rendered correctly.
|
||||
|
||||
```unison
|
||||
(.) f g x = f (g x)
|
||||
(`.`) f g x = f (g x)
|
||||
|
||||
use Boolean not
|
||||
|
||||
noop = not . not
|
||||
noop = not `.` not
|
||||
```
|
||||
|
||||
```ucm
|
||||
@ -18,8 +18,7 @@ noop = not . not
|
||||
|
||||
⍟ These new definitions are ok to `add`:
|
||||
|
||||
. : ∀ i1 g1 o i g.
|
||||
(i1 ->{g1} o) -> (i ->{g} i1) -> i ->{g1, g} o
|
||||
`.` : (i1 ->{g1} o) -> (i ->{g} i1) -> i ->{g1, g} o
|
||||
noop : Boolean -> Boolean
|
||||
|
||||
```
|
||||
@ -28,8 +27,7 @@ noop = not . not
|
||||
|
||||
⍟ I've added these definitions:
|
||||
|
||||
. : ∀ i1 g1 o i g.
|
||||
(i1 ->{g1} o) -> (i ->{g} i1) -> i ->{g1, g} o
|
||||
`.` : (i1 ->{g1} o) -> (i ->{g} i1) -> i ->{g1, g} o
|
||||
noop : Boolean -> Boolean
|
||||
|
||||
.> view noop
|
||||
@ -37,6 +35,6 @@ noop = not . not
|
||||
noop : Boolean -> Boolean
|
||||
noop =
|
||||
use Boolean not
|
||||
not . not
|
||||
not `.` not
|
||||
|
||||
```
|
||||
|
@ -11,10 +11,10 @@ strategies.
|
||||
```
|
||||
|
||||
```unison
|
||||
(.) : (b ->{e} c) -> (a ->{e} b) -> a ->{e} c
|
||||
(.) f g x = f (g x)
|
||||
(<<) : (b ->{e} c) -> (a ->{e} b) -> a ->{e} c
|
||||
(<<) f g x = f (g x)
|
||||
|
||||
f = atan . tan
|
||||
f = atan << tan
|
||||
|
||||
foldl : (b ->{e} a ->{e} b) -> b -> [a] ->{e} b
|
||||
foldl f a = cases
|
||||
|
@ -7,10 +7,10 @@ the choices may not work equally well with the type checking
|
||||
strategies.
|
||||
|
||||
```unison
|
||||
(.) : (b ->{e} c) -> (a ->{e} b) -> a ->{e} c
|
||||
(.) f g x = f (g x)
|
||||
(<<) : (b ->{e} c) -> (a ->{e} b) -> a ->{e} c
|
||||
(<<) f g x = f (g x)
|
||||
|
||||
f = atan . tan
|
||||
f = atan << tan
|
||||
|
||||
foldl : (b ->{e} a ->{e} b) -> b -> [a] ->{e} b
|
||||
foldl f a = cases
|
||||
@ -30,7 +30,7 @@ txt = foldl (Text.++) "" ["a", "b", "c"]
|
||||
|
||||
⍟ These new definitions are ok to `add`:
|
||||
|
||||
. : (b ->{e} c) -> (a ->{e} b) -> a ->{e} c
|
||||
<< : (b ->{e} c) -> (a ->{e} b) -> a ->{e} c
|
||||
f : Float -> Float
|
||||
foldl : (b ->{e} a ->{e} b) -> b -> [a] ->{e} b
|
||||
txt : Text
|
||||
@ -41,7 +41,7 @@ txt = foldl (Text.++) "" ["a", "b", "c"]
|
||||
|
||||
⍟ I've added these definitions:
|
||||
|
||||
. : (b ->{e} c) -> (a ->{e} b) -> a ->{e} c
|
||||
<< : (b ->{e} c) -> (a ->{e} b) -> a ->{e} c
|
||||
f : Float -> Float
|
||||
foldl : (b ->{e} a ->{e} b) -> b -> [a] ->{e} b
|
||||
txt : Text
|
||||
|
@ -59,14 +59,15 @@ unique type subnamespace.AType = A | B
|
||||
-- Should tab complete namespaces since they may contain terms/types
|
||||
.> debug.tab-complete view sub
|
||||
|
||||
subnamespace.
|
||||
subnamespace2.
|
||||
|
||||
|
||||
-- Should not complete things from child namespaces of the current query if there are other completions at this level
|
||||
.> debug.tab-complete view subnamespace
|
||||
|
||||
subnamespace.
|
||||
subnamespace2.
|
||||
* subnamespace.AType
|
||||
subnamespace.AType.
|
||||
* subnamespace.someName
|
||||
* subnamespace.someOtherName
|
||||
|
||||
-- Should complete things from child namespaces of the current query if it's dot-suffixed
|
||||
.> debug.tab-complete view subnamespace.
|
||||
@ -79,24 +80,21 @@ unique type subnamespace.AType = A | B
|
||||
-- Should complete things from child namespaces of the current query if there are no more completions at this level.
|
||||
.> debug.tab-complete view subnamespace2
|
||||
|
||||
subnamespace2.
|
||||
* subnamespace2.thing
|
||||
|
||||
-- Should prefix-filter by query suffix
|
||||
.> debug.tab-complete view subnamespace.some
|
||||
|
||||
* subnamespace.someName
|
||||
* subnamespace.someOtherName
|
||||
|
||||
|
||||
.> debug.tab-complete view subnamespace.someOther
|
||||
|
||||
* subnamespace.someOtherName
|
||||
|
||||
|
||||
-- Should tab complete absolute names
|
||||
.othernamespace> debug.tab-complete view .subnamespace.some
|
||||
|
||||
* .subnamespace.someName
|
||||
* .subnamespace.someOtherName
|
||||
|
||||
|
||||
```
|
||||
## Tab complete namespaces
|
||||
@ -105,13 +103,11 @@ unique type subnamespace.AType = A | B
|
||||
-- Should tab complete namespaces
|
||||
.> debug.tab-complete cd sub
|
||||
|
||||
subnamespace
|
||||
subnamespace2
|
||||
|
||||
|
||||
.> debug.tab-complete cd subnamespace
|
||||
|
||||
subnamespace
|
||||
subnamespace2
|
||||
subnamespace.AType
|
||||
|
||||
.> debug.tab-complete cd subnamespace.
|
||||
|
||||
@ -119,13 +115,13 @@ unique type subnamespace.AType = A | B
|
||||
|
||||
.> debug.tab-complete io.test sub
|
||||
|
||||
subnamespace.
|
||||
subnamespace2.
|
||||
|
||||
|
||||
.> debug.tab-complete io.test subnamespace
|
||||
|
||||
subnamespace.
|
||||
subnamespace2.
|
||||
subnamespace.AType.
|
||||
* subnamespace.someName
|
||||
* subnamespace.someOtherName
|
||||
|
||||
.> debug.tab-complete io.test subnamespace.
|
||||
|
||||
@ -166,12 +162,11 @@ add b = b
|
||||
|
||||
.> debug.tab-complete delete.type Foo
|
||||
|
||||
* Foo
|
||||
Foo.
|
||||
|
||||
|
||||
.> debug.tab-complete delete.term add
|
||||
|
||||
* add
|
||||
|
||||
|
||||
```
|
||||
## Tab complete projects and branches
|
||||
@ -238,6 +233,5 @@ myproject/main> add
|
||||
myproject/main> debug.tab-complete merge mybr
|
||||
|
||||
/mybranch
|
||||
mybranchsubnamespace
|
||||
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user