Skip to content

Commit 1003f82

Browse files
randomly change score until tests do what i want
1 parent 7413aa1 commit 1003f82

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

crates/pg_completions/src/relevance.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ impl<'a> CompletionRelevance<'a> {
7070
Some(ct) => ct,
7171
};
7272

73+
let has_mentioned_tables = ctx.mentioned_relations.len() > 0;
74+
7375
self.score += match self.data {
7476
CompletionRelevanceData::Table(_) => match clause_type {
7577
ClauseType::From => 5,
@@ -78,13 +80,15 @@ impl<'a> CompletionRelevance<'a> {
7880
_ => -50,
7981
},
8082
CompletionRelevanceData::Function(_) => match clause_type {
81-
ClauseType::Select => 5,
83+
ClauseType::Select if !has_mentioned_tables => 15,
84+
ClauseType::Select if has_mentioned_tables => 0,
8285
ClauseType::From => 0,
8386
_ => -50,
8487
},
8588
CompletionRelevanceData::Column(_) => match clause_type {
86-
ClauseType::Select => 15,
87-
ClauseType::Where => 15,
89+
ClauseType::Select if has_mentioned_tables => 10,
90+
ClauseType::Select if !has_mentioned_tables => 0,
91+
ClauseType::Where => 10,
8892
_ => -15,
8993
},
9094
}
@@ -96,7 +100,7 @@ impl<'a> CompletionRelevance<'a> {
96100
if ctx.is_invocation {
97101
30
98102
} else {
99-
-30
103+
-10
100104
}
101105
}
102106
_ => {

crates/pg_lsp/src/utils/to_lsp_types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ pub fn to_completion_kind(
66
match kind {
77
pg_completions::CompletionItemKind::Table => lsp_types::CompletionItemKind::CLASS,
88
pg_completions::CompletionItemKind::Function => lsp_types::CompletionItemKind::FUNCTION,
9+
pg_completions::CompletionItemKind::Column => lsp_types::CompletionItemKind::FIELD,
910
}
1011
}

crates/pg_lsp_new/src/handlers/completions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ fn to_lsp_types_completion_item_kind(
5454
pg_comp_kind: pg_completions::CompletionItemKind,
5555
) -> lsp_types::CompletionItemKind {
5656
match pg_comp_kind {
57-
pg_completions::CompletionItemKind::Function
58-
| pg_completions::CompletionItemKind::Table => lsp_types::CompletionItemKind::CLASS,
57+
pg_completions::CompletionItemKind::Function => lsp_types::CompletionItemKind::FUNCTION,
58+
pg_completions::CompletionItemKind::Table => lsp_types::CompletionItemKind::CLASS,
5959
pg_completions::CompletionItemKind::Column => lsp_types::CompletionItemKind::FIELD,
6060
}
6161
}

0 commit comments

Comments
 (0)