We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5e0d5cb commit cdd37d0Copy full SHA for cdd37d0
5 files changed
internal/cli/cli.go
@@ -136,6 +136,7 @@ func Main(version string, buildDate string) int {
136
if errors.As(err, &depErr) {
137
executor.PrintDependencyTree(depErr, os.Stderr)
138
log.Errorf("%s", depErr.FailureMessage())
139
+
140
return getExitCode(err, 1)
141
}
142
internal/lsp/handlers.go
@@ -91,6 +91,7 @@ func (h *definitionHandler) findMixinsDefinition(doc *string, params *lsp.Defini
91
92
func (h *definitionHandler) findCommandDefinition(doc *string, params *lsp.DefinitionParams) (any, error) {
93
path := normalizePath(params.TextDocument.URI)
94
95
commandName := h.parser.extractCommandReference(doc, params.Position)
96
if commandName == "" {
97
h.parser.log.Debugf("no command reference resolved at %s:%d:%d", path, params.Position.Line, params.Position.Character)
internal/lsp/server.go
@@ -25,8 +25,8 @@ func (s *lspServer) Run() error {
25
return s.server.RunStdio()
26
27
28
-func lspLogVerbosity() (verbosity int) {
29
- verbosity = 1
+func lspLogVerbosity() int {
+ verbosity := 1
30
31
defer func() {
32
_ = recover()
internal/lsp/treesitter.go
@@ -106,49 +106,6 @@ func executeYAMLQuery(document *string, queryText string, visit func(capture ts.
106
return false
107
108
109
-func getLine(document *string, line uint32) string {
110
- lines := strings.Split(*document, "\n")
111
- if line >= uint32(len(lines)) {
112
- return ""
113
- }
114
-
115
- return lines[line]
116
-}
117
118
-// position.
119
-func wordUnderCursor(text string, position *lsp.Position) string {
120
- if len(text) == 0 {
121
122
123
124
- character := position.Character
125
126
- if character >= uint32(len(text)) {
127
128
129
130
- if text[character] == ' ' {
131
132
133
134
- // Find word boundaries
135
- start := position.Character
- for start > 0 && isWordChar(text[start-1]) {
- start--
- end := position.Character
- for end < uint32(len(text)) && isWordChar(text[end]) {
- end++
143
144
145
- return text[start:end]
146
147
148
-func isWordChar(c byte) bool {
149
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_' || c == '-'
150
151
152
type parser struct {
153
log commonlog.Logger
154
@@ -457,8 +414,10 @@ func (p *parser) findCommandNameByAnchor(document *string, anchorName string) st
457
414
break
458
415
459
416
460
- var commandName string
461
- var matchedAnchor string
417
+ var (
418
+ commandName string
419
+ matchedAnchor string
420
+ )
462
421
463
422
for _, capture := range match.Captures {
464
423
switch capture.Name {
internal/lsp/treesitter_test.go
@@ -694,28 +694,3 @@ commands:
694
t.Fatalf("extractDependsValues() = %#v, want %#v", got, want)
695
696
697
698
-func TestWordUnderCursor(t *testing.T) {
699
- tests := []struct {
700
- line string
701
- position lsp.Position
702
- want string
703
- }{
704
- {"test word here", lsp.Position{Character: 0}, "test"},
705
- {"test word here", lsp.Position{Character: 2}, "test"},
706
- {"test word here", lsp.Position{Character: 5}, "word"},
707
- {"test word here", lsp.Position{Character: 10}, "here"},
708
- {"test-word_123", lsp.Position{Character: 5}, "test-word_123"},
709
- {"", lsp.Position{Character: 0}, ""},
710
- {"test", lsp.Position{Character: 10}, ""},
711
- {"test word", lsp.Position{Character: 4}, ""},
712
- {" test ", lsp.Position{Character: 3}, "test"},
713
714
715
- for i, tt := range tests {
716
- got := wordUnderCursor(tt.line, &tt.position)
717
- if got != tt.want {
718
- t.Errorf("case %d: got %q, want %q", i, got, tt.want)
719
720
721
0 commit comments