Skip to content

Commit

Permalink
Fix issue with swizzle
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielGavin committed Sep 26, 2023
1 parent 5e5e5b7 commit 07fae9a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
34 changes: 19 additions & 15 deletions src/server/completion.odin
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ get_selector_completion :: proc(
if s, ok := selector.value.(SymbolProcedureValue); ok {
if len(s.return_types) == 1 {
if selector, ok = resolve_type_expression(
ast_context,
s.return_types[0].type,
); !ok {
ast_context,
s.return_types[0].type,
); !ok {
return
}
}
Expand Down Expand Up @@ -361,9 +361,9 @@ get_selector_completion :: proc(
if field != "" {
for i := 0; i < len(field); i += 1 {
c := field[i]
if _, ok := swizzle_color_components[c]; ok {
if _, ok := swizzle_color_map[c]; ok {
containsColor += 1
} else if _, ok := swizzle_coord_components[c]; ok {
} else if _, ok := swizzle_coord_map[c]; ok {
containsCoord += 1
}
}
Expand All @@ -379,10 +379,10 @@ get_selector_completion :: proc(
expr_len -= 1

item := CompletionItem {
label = fmt.tprintf("%v%c", field, k),
label = fmt.tprintf("%v%v", field, k),
kind = .Property,
detail = fmt.tprintf(
"%v%c: %v",
"%v%v: %v",
field,
k,
common.node_to_string(v.expr),
Expand All @@ -401,10 +401,10 @@ get_selector_completion :: proc(
expr_len -= 1

item := CompletionItem {
label = fmt.tprintf("%v%c", field, k),
label = fmt.tprintf("%v%v", field, k),
kind = .Property,
detail = fmt.tprintf(
"%v%c: %v",
"%v%v: %v",
field,
k,
common.node_to_string(v.expr),
Expand All @@ -423,10 +423,10 @@ get_selector_completion :: proc(
expr_len -= 1

item := CompletionItem {
label = fmt.tprintf("%v%c", field, k),
label = fmt.tprintf("%v%v", field, k),
kind = .Property,
detail = fmt.tprintf(
"%v%c: [%v]%v",
"%v%v: [%v]%v",
field,
k,
containsColor,
Expand All @@ -444,10 +444,10 @@ get_selector_completion :: proc(
expr_len -= 1

item := CompletionItem {
label = fmt.tprintf("%v%c", field, k),
label = fmt.tprintf("%v%v", field, k),
kind = .Property,
detail = fmt.tprintf(
"%v%c: [%v]%v",
"%v%v: [%v]%v",
field,
k,
containsCoord,
Expand Down Expand Up @@ -1926,16 +1926,20 @@ language_keywords: []string = {
"or_else",
}

swizzle_color_components: map[u8]bool = {
swizzle_color_map: map[u8]bool = {
'r' = true,
'g' = true,
'b' = true,
'a' = true,
}

swizzle_coord_components: map[u8]bool = {
swizzle_color_components: []string = {"r", "g", "b", "a"}

swizzle_coord_map: map[u8]bool = {
'x' = true,
'y' = true,
'z' = true,
'w' = true,
}

swizzle_coord_components: []string = {"x", "y", "z", "w"}
6 changes: 0 additions & 6 deletions tests/completions_test.odin
Original file line number Diff line number Diff line change
Expand Up @@ -526,18 +526,12 @@ ast_swizzle_completion_few_components :: proc(t: ^testing.T) {
packages = {},
}

my_array: [2]f32


/*
FIXME
test.expect_completion_details(
t,
&source,
".",
{"xx: [2]f32", "xy: [2]f32"},
)
*/
}


Expand Down

0 comments on commit 07fae9a

Please sign in to comment.