mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 18:07:51 +08:00
edit: terminate completion early if current token has no node
This commit is contained in:
parent
ea2b7e8b92
commit
c0d783996e
|
@ -1,5 +1,6 @@
|
|||
package edit
|
||||
|
||||
// Styles for UI.
|
||||
var (
|
||||
attrForPrompt = ""
|
||||
attrForRprompt = "7"
|
||||
|
@ -11,6 +12,12 @@ var (
|
|||
attrForSelectedFile = ";7"
|
||||
)
|
||||
|
||||
// Styles for semantic coloring.
|
||||
var (
|
||||
styleForBadCommand = "31;3"
|
||||
styleForBadVariable = "31;3"
|
||||
)
|
||||
|
||||
var attrForType = map[TokenType]string{
|
||||
ParserError: "31;3",
|
||||
Bareword: "",
|
||||
|
|
|
@ -59,6 +59,9 @@ func (c *completion) next(cycle bool) {
|
|||
func startCompletion(ed *Editor, k Key) *leReturn {
|
||||
token := tokenAtDot(ed)
|
||||
node := token.Node
|
||||
if node == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
c := &completion{
|
||||
start: node.Begin(),
|
||||
|
|
|
@ -178,6 +178,11 @@ func (ed *Editor) refresh() error {
|
|||
if ed.mode != modeCompletion {
|
||||
// XXX Ignore error
|
||||
ed.tokens, _ = tokenize(ed.line)
|
||||
for _, t := range ed.tokens {
|
||||
for _, colorist := range colorists {
|
||||
t.MoreStyle += colorist(t.Node, ed.evaler)
|
||||
}
|
||||
}
|
||||
}
|
||||
return ed.writer.refresh(&ed.editorState)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user