Skip to content

Commit 21217b5

Browse files
commitered
1 parent cf0c98d commit 21217b5

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

crates/pgls_completions/src/providers/columns.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ mod tests {
5353
use pgls_test_utils::QueryWithCursorPosition;
5454
use sqlx::PgPool;
5555

56-
use crate::test_helper::{TestCompletionsCase, TestCompletionsSuite, assert_complete_results};
56+
use crate::test_helper::{TestCompletionsCase, TestCompletionsSuite};
5757

5858
#[sqlx::test(migrator = "pgls_test_utils::MIGRATIONS")]
5959
async fn handles_nested_queries(pool: PgPool) {
@@ -440,9 +440,9 @@ mod tests {
440440
"select name from instruments i join others o on i.z = o.a <sql>",
441441
)
442442
.type_sql("where o.<1>a = <2>i.z and <3>i.id > 5;")
443-
.comment("should respect alias speciifcation")
444-
.comment("should not prioritize suggest columns or schemas (right side of binary expression)")
445-
.comment("should prioritize columns that aren't already mentioned")
443+
.comment("should respect alias speciifcation")
444+
.comment("should not prioritize suggest columns or schemas (right side of binary expression)")
445+
.comment("should prioritize columns that aren't already mentioned"),
446446
)
447447
.snapshot("suggests_columns_in_where_clause")
448448
.await;

crates/pgls_completions/src/relevance/filtering.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use pgls_schema_cache::ProcKind;
22
use pgls_treesitter::context::{TreesitterContext, WrappingClause, WrappingNode};
33

4-
use crate::is_sanitized_token;
54

65
use super::CompletionRelevanceData;
76

@@ -117,7 +116,8 @@ impl CompletionFilter<'_> {
117116
"column_reference_1of1",
118117
"column_reference_2of2",
119118
"column_reference_3of3",
120-
]) && !ctx.node_under_cursor_is_within_field(&["binary_expr_right"])
119+
]) && (!ctx.node_under_cursor_is_within_field(&["binary_expr_right"])
120+
|| ctx.has_any_qualifier())
121121
}
122122

123123
CompletionRelevanceData::Schema(_) => ctx.node_under_cursor_is_within_field(&[

crates/pgls_completions/src/relevance/scoring.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use fuzzy_matcher::{FuzzyMatcher, skim::SkimMatcherV2};
22

3-
use pgls_treesitter::context::{TreesitterContext, WrappingClause, WrappingNode};
3+
use pgls_treesitter::context::{TreesitterContext, WrappingClause};
44

55
use crate::sanitization;
66

crates/pgls_completions/src/snapshots/pgls_completions__test_helper__suggests_columns_in_where_clause.snap

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ pg_catalog - pg_catalog (Schema)
5757
--------------
5858

5959
select name from instruments i join others o on i.z = o.a where o.a = i.|
60+
61+
Results:
62+
created_at - public.instruments.created_at (Column)
63+
id - public.instruments.id (Column)
64+
name - public.instruments.name (Column)
65+
z - public.instruments.z (Column)
66+
67+
--------------
68+
6069
select name from instruments i join others o on i.z = o.a where o.a = i.z |
6170
select name from instruments i join others o on i.z = o.a where o.a = i.z a|
6271
select name from instruments i join others o on i.z = o.a where o.a = i.z and |
@@ -72,7 +81,22 @@ i.name - public.instruments.name (Column)
7281
--------------
7382

7483
select name from instruments i join others o on i.z = o.a where o.a = i.z and i.|
84+
85+
Results:
86+
created_at - public.instruments.created_at (Column)
87+
id - public.instruments.id (Column)
88+
name - public.instruments.name (Column)
89+
z - public.instruments.z (Column)
90+
91+
--------------
92+
7593
select name from instruments i join others o on i.z = o.a where o.a = i.z and i.i|
94+
95+
Results:
96+
id - public.instruments.id (Column)
97+
98+
--------------
99+
76100
select name from instruments i join others o on i.z = o.a where o.a = i.z and i.id |
77101
select name from instruments i join others o on i.z = o.a where o.a = i.z and i.id > |
78102

crates/pgls_treesitter/src/context/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ impl<'a> TreesitterContext<'a> {
382382
{
383383
// if the cursor is exactly at the start of a punctuation node,
384384
// prefer the previous sibling (e.g., when cursor is at "i|," prefer "i" over ",")
385-
let is_punctuation = matches!(current_node.kind(), "," | ")" | ";");
385+
let is_punctuation = matches!(current_node.kind(), "," | ")");
386386
if is_punctuation && current_node.start_byte() == self.position {
387387
if let Some(prev) = current_node.prev_sibling() {
388388
if prev.end_byte() == self.position {

0 commit comments

Comments
 (0)