diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/fuzzy.odin | 16 | ||||
| -rw-r--r-- | src/index/memory_index.odin | 2 | ||||
| -rw-r--r-- | src/server/completion.odin | 26 |
3 files changed, 22 insertions, 22 deletions
diff --git a/src/common/fuzzy.odin b/src/common/fuzzy.odin index cf4d82c..68223e0 100644 --- a/src/common/fuzzy.odin +++ b/src/common/fuzzy.odin @@ -148,20 +148,20 @@ fuzzy_to_acronym :: proc(word: string) -> (string, bool) { return str, true; } - -fuzzy_match :: proc(matcher: ^FuzzyMatcher, word: string) -> (f32, bool) { - +//changed from bool to int because of a linux bug - 10.05.2021 +fuzzy_match :: proc(matcher: ^FuzzyMatcher, word: string) -> (f32, int) { + if !fuzzy_init(matcher, word) { - return 0, false; + return 0, 0; } if matcher.pattern_count <= 0 { - return 1, true; + return 1, 1; } if acronym, ok := fuzzy_to_acronym(word); ok { if acronym == matcher.pattern { - return 20, true; + return 20, 1; } } @@ -171,7 +171,7 @@ fuzzy_match :: proc(matcher: ^FuzzyMatcher, word: string) -> (f32, bool) { cast(int)matcher.scores[matcher.pattern_count][matcher.word_count][match].score); if fuzzy_is_awful(best) { - return 0.0, false; + return 0.0, 0; } score := matcher.score_scale * min(perfect_bonus * cast(f32)matcher.pattern_count, cast(f32)max(0, best)); @@ -180,7 +180,7 @@ fuzzy_match :: proc(matcher: ^FuzzyMatcher, word: string) -> (f32, bool) { score *= 2; } - return score, true; + return score, 1; } fuzzy_is_awful :: proc(s: int) -> bool { diff --git a/src/index/memory_index.odin b/src/index/memory_index.odin index 4ec12f6..93c7ded 100644 --- a/src/index/memory_index.odin +++ b/src/index/memory_index.odin @@ -44,7 +44,7 @@ memory_index_fuzzy_search :: proc(index: ^MemoryIndex, name: string, pkgs: []str continue; } - if score, ok := common.fuzzy_match(fuzzy_matcher, symbol.name); ok { + if score, ok := common.fuzzy_match(fuzzy_matcher, symbol.name); ok == 1 { result := FuzzyResult { symbol = symbol, score = score, diff --git a/src/server/completion.odin b/src/server/completion.odin index 3fc4917..8c16268 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -867,7 +867,7 @@ get_identifier_completion :: proc(ast_context: ^AstContext, position_context: ^D build_symbol_return(&symbol); build_symbol_signature(&symbol); - if score, ok := common.fuzzy_match(matcher, symbol.name); ok { + if score, ok := common.fuzzy_match(matcher, symbol.name); ok == 1 { append(&combined, CombinedResult {score = score * 1.1, symbol = symbol, variable = ident}); } } @@ -893,7 +893,7 @@ get_identifier_completion :: proc(ast_context: ^AstContext, position_context: ^D build_symbol_return(&symbol); build_symbol_signature(&symbol); - if score, ok := common.fuzzy_match(matcher, symbol.name); ok { + if score, ok := common.fuzzy_match(matcher, symbol.name); ok == 1 { append(&combined, CombinedResult {score = score * 1.1, symbol = symbol, variable = ident}); } } @@ -910,7 +910,7 @@ get_identifier_completion :: proc(ast_context: ^AstContext, position_context: ^D type = .Package, }; - if score, ok := common.fuzzy_match(matcher, symbol.name); ok { + if score, ok := common.fuzzy_match(matcher, symbol.name); ok == 1 { append(&combined, CombinedResult {score = score * 1.1, symbol = symbol}); } } @@ -922,19 +922,11 @@ get_identifier_completion :: proc(ast_context: ^AstContext, position_context: ^D type = .Keyword, }; - if score, ok := common.fuzzy_match(matcher, keyword); ok { + if score, ok := common.fuzzy_match(matcher, keyword); ok == 1 { append(&combined, CombinedResult {score = score * 1.1, symbol = symbol}); } } - language_keywords: []string = { - "align_of","case","defer","enum","import","proc","transmute","when", - "auto_cast","cast","distinct","fallthrough","in","notin","return","type_of", - "bit_field","const","do","for","inline","offset_of","size_of","typeid", - "bit_set","context","dynamic","foreign","opaque","struct","union", - "break","continue","else","if","map","package","switch","using", - }; - for keyword, _ in language_keywords { symbol := index.Symbol { @@ -942,7 +934,7 @@ get_identifier_completion :: proc(ast_context: ^AstContext, position_context: ^D type = .Keyword, }; - if score, ok := common.fuzzy_match(matcher, keyword); ok { + if score, ok := common.fuzzy_match(matcher, keyword); ok == 1 { append(&combined, CombinedResult {score = score * 1.1, symbol = symbol}); } } @@ -1149,3 +1141,11 @@ is_bitset_binary_operator :: proc(op: string) -> bool { is_bitset_assignment_operator :: proc(op: string) -> bool { return op in bitset_assignment_operators; } + +language_keywords: []string = { + "align_of","case","defer","enum","import","proc","transmute","when", + "auto_cast","cast","distinct","fallthrough","in","notin","return","type_of", + "bit_field","const","do","for","inline","offset_of","size_of","typeid", + "bit_set","context","dynamic","foreign","opaque","struct","union", + "break","continue","else","if","map","package","switch","using", +};
\ No newline at end of file |