Repository navigation
Only complete to cabal-version at first line - #5119
StillerHarpo wants to merge 5 commits into
Conversation
beffa25 to
509d988
Compare
|
Looks good |
3602e17 to
b076316
Compare
| Just section@(Syntax.Section _ args sectionFields) | ||
| | cursorRow == 1 -> (TopLevel, CabalVersion) |
There was a problem hiding this comment.
I think this case is impossible, no?
I guess it can only happen if you have library { cabal-version: ... }, but we don't want to offer the completion in this case any way, so the context should likely not use the special case any way.
There was a problem hiding this comment.
No, if I remove this cabal-version is only suggested in empty files
only suggest cabal-version at start of file with some input: FAIL (0.03s)
plugins/hls-cabal-plugin/test/Completer.hs:94:
expected: ["cabal-version:"]
but got: ["category:","package-url:","benchmark","executable"]
Use -p '$0=="Cabal Plugin Tests.Completer Tests.Basic Completer Tests.only suggest cabal-version at start of file with some input"' to rerun this test only.
| | -- | Point is in the first line of the file and cabal version is missing | ||
| CabalVersion |
There was a problem hiding this comment.
I am wondering whether we rather want to say the StanzaContext is FirstLine, so we don't need the special key the for cabal-version. Then cabal-version is just a normal FieldContext, might work out a little better?
There was a problem hiding this comment.
I now don't handle all FirstLine is not quite right, because if the cursor is after a key word in the first line we don't want to complete to cabal-version. Should I put it in the StanzaContext and call it CabalVersionFirstLine contexts as cabal-version
| Just l -> l | ||
| contextToCompleter (TopLevel, CabalVersion) = constantCompleter ["cabal-version:"] | ||
| -- If we are at the start of a file, we should be in the toplevel stanza | ||
| contextToCompleter (Stanza _ _, CabalVersion) = errorNoopCompleter LogNotInTopLevelStanzaAtStartOfFirstLine |
There was a problem hiding this comment.
In particular, this case should be impossible (and is). If we made the special case in StanzaContext, this case goes away.
The field cabal-version has to be in the first line. So any other field completion doesn't make sense.
It is only valid in first line
b076316 to
0bb56d6
Compare
The field cabal-version has to be in the first line. So any other
field completion doesn't make sense.
#5115