Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions cmd/vibes/lsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"os"
"regexp"
"slices"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -345,15 +346,11 @@ func completionItems() []map[string]any {
}

func classifyWord(word string) string {
for _, keyword := range lspKeywords {
if keyword == word {
return "keyword"
}
if slices.Contains(lspKeywords, word) {
return "keyword"
}
for _, builtin := range lspBuiltins {
if builtin == word {
return "builtin"
}
if slices.Contains(lspBuiltins, word) {
return "builtin"
}
return "symbol"
}
Expand All @@ -372,10 +369,7 @@ func wordAtPosition(source string, line, character int) string {
if character < 0 {
character = 0
}
character = utf16OffsetToRuneIndex(lineText, character)
if character > len(runes) {
character = len(runes)
}
character = min(utf16OffsetToRuneIndex(lineText, character), len(runes))

cursor := character
if cursor == len(runes) {
Expand Down
8 changes: 4 additions & 4 deletions vibes/capability_contracts_cycles.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package vibes

import "slices"

import "reflect"

type capabilityCycleScanner struct {
Expand Down Expand Up @@ -34,10 +36,8 @@ func (s *capabilityCycleScanner) containsCycle(val Value) bool {
return true
}
s.visitingArrays[id] = struct{}{}
for _, item := range values {
if s.containsCycle(item) {
return true
}
if slices.ContainsFunc(values, s.containsCycle) {
return true
}
delete(s.visitingArrays, id)
s.seenArrays[id] = struct{}{}
Expand Down
5 changes: 1 addition & 4 deletions vibes/execution_members_array_transforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,7 @@ func arrayMemberTransforms(property string) (Value, error) {
}
chunks := make([]Value, 0, chunkCapacity)
for i := 0; i < len(arr); i += size {
end := i + size
if end > len(arr) {
end = len(arr)
}
end := min(i+size, len(arr))
part := make([]Value, end-i)
copy(part, arr[i:end])
chunks = append(chunks, NewArray(part))
Expand Down
2 changes: 1 addition & 1 deletion vibes/execution_members_string_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func stringTemplateOption(kwargs map[string]Value) (bool, error) {

func stringTemplateLookup(context Value, keyPath string) (Value, bool) {
current := context
for _, segment := range strings.Split(keyPath, ".") {
for segment := range strings.SplitSeq(keyPath, ".") {
if segment == "" {
return NewNil(), false
}
Expand Down