diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-07-14 22:51:52 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-07-14 22:51:52 +0200 |
| commit | b9076a8f7c6a1c9b55b177cccb7f6f47bec6cb34 (patch) | |
| tree | f08d4d7a96d46d6eaf4d5b57d9b54c54856ab996 | |
| parent | 755ee87a48db7eff9790a6e7d438a168cfaa5256 (diff) | |
odinfmt fixes + more tests
| -rw-r--r-- | src/common/fuzzy.odin | 8 | ||||
| -rw-r--r-- | src/odin/printer/visit.odin | 2 | ||||
| -rw-r--r-- | tools/odinfmt/tests/.snapshots/selectors.odin | 6 | ||||
| -rw-r--r-- | tools/odinfmt/tests/selectors.odin | 5 |
4 files changed, 12 insertions, 9 deletions
diff --git a/src/common/fuzzy.odin b/src/common/fuzzy.odin index adc6a98..04bb0ad 100644 --- a/src/common/fuzzy.odin +++ b/src/common/fuzzy.odin @@ -78,7 +78,6 @@ char_types: []u8 = { } make_fuzzy_matcher :: proc(pattern: string, allocator := context.temp_allocator) -> ^FuzzyMatcher { - matcher := new(FuzzyMatcher, allocator) matcher.pattern_count = min(len(pattern), max_pattern) @@ -117,7 +116,6 @@ make_fuzzy_matcher :: proc(pattern: string, allocator := context.temp_allocator) } fuzzy_to_acronym :: proc(word: string) -> (string, bool) { - builder := strings.builder_make(context.temp_allocator) if len(word) <= 1 { @@ -226,7 +224,6 @@ fuzzy_packed_lookup :: proc(data: $A/[]$T, i: uint) -> T { } fuzzy_init :: proc(matcher: ^FuzzyMatcher, word: string) -> bool { - matcher.word = word matcher.word_count = min(max_word, len(matcher.word)) @@ -260,7 +257,6 @@ fuzzy_init :: proc(matcher: ^FuzzyMatcher, word: string) -> bool { } fuzzy_skip_penalty :: proc(matcher: ^FuzzyMatcher, w: int) -> int { - if w == 0 { // Skipping the first character. return 3 } @@ -273,7 +269,6 @@ fuzzy_skip_penalty :: proc(matcher: ^FuzzyMatcher, w: int) -> int { } fuzzy_build_graph :: proc(matcher: ^FuzzyMatcher) { - for w := 0; w < matcher.word_count; w += 1 { s: FuzzyScoreInfo @@ -294,7 +289,6 @@ fuzzy_build_graph :: proc(matcher: ^FuzzyMatcher) { } for p := 0; p < matcher.pattern_count; p += 1 { - for w := p; w < matcher.word_count; w += 1 { score := &matcher.scores[p + 1][w + 1] pre_miss := &matcher.scores[p + 1][w] @@ -341,7 +335,6 @@ fuzzy_build_graph :: proc(matcher: ^FuzzyMatcher) { } fuzzy_match_bonus :: proc(matcher: ^FuzzyMatcher, p: int, w: int, last: int) -> int { - assert(matcher.lower_pattern[p] == matcher.lower_word[w]) s := 1 @@ -390,7 +383,6 @@ fuzzy_match_bonus :: proc(matcher: ^FuzzyMatcher, p: int, w: int, last: int) -> } fuzzy_allow_match :: proc(matcher: ^FuzzyMatcher, p: int, w: int, last: int) -> bool { - if matcher.lower_pattern[p] != matcher.lower_word[w] { return false } diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index faec0dd..91652a5 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -344,7 +344,7 @@ is_call_expr_nestable :: proc(list: []^ast.Expr) -> bool { is_values_nestable_assign :: proc(list: []^ast.Expr) -> bool { for expr in list { #partial switch v in expr.derived { - case ^ast.Ident, ^ast.Binary_Expr, ^ast.Index_Expr, ^ast.Ternary_If_Expr, ^ast.Ternary_When_Expr, ^ast.Or_Else_Expr, ^ast.Or_Return_Expr: + case ^ast.Ident, ^ast.Binary_Expr, ^ast.Index_Expr, ^ast.Selector_Expr, ^ast.Ternary_If_Expr, ^ast.Ternary_When_Expr, ^ast.Or_Else_Expr, ^ast.Or_Return_Expr: return true } } diff --git a/tools/odinfmt/tests/.snapshots/selectors.odin b/tools/odinfmt/tests/.snapshots/selectors.odin new file mode 100644 index 0000000..b56a62d --- /dev/null +++ b/tools/odinfmt/tests/.snapshots/selectors.odin @@ -0,0 +1,6 @@ +package odinfmt_test + +main :: proc() { + app_state.scene_framebuffer, app_state.scene_framebuffer_swap = + app_state.scene_framebuffer_swap, app_state.scene_framebuffer +} diff --git a/tools/odinfmt/tests/selectors.odin b/tools/odinfmt/tests/selectors.odin new file mode 100644 index 0000000..1cfd2ad --- /dev/null +++ b/tools/odinfmt/tests/selectors.odin @@ -0,0 +1,5 @@ +package odinfmt_test + +main :: proc() { + app_state.scene_framebuffer, app_state.scene_framebuffer_swap = app_state.scene_framebuffer_swap, app_state.scene_framebuffer +}
\ No newline at end of file |