@@ -245,7 +245,7 @@ drop table t$0;
245245 }
246246
247247 #[ test]
248- fn goto_definition_on_dot_prefers_previous_token ( ) {
248+ fn goto_definition_prefers_previous_token ( ) {
249249 assert_snapshot ! ( goto( "
250250create table t(a int);
251251select t.$0a from t;
@@ -256,6 +256,50 @@ select t.$0a from t;
256256 3 │ select t.a from t;
257257 ╰╴ ─ 1. source
258258 " ) ;
259+
260+ assert_snapshot ! ( goto( "
261+ create type ty as (a int, b int);
262+ with t as (select '(1,2)'::ty c)
263+ select (c)$0.a from t;
264+ " ) , @r"
265+ ╭▸
266+ 3 │ with t as (select '(1,2)'::ty c)
267+ │ ─ 2. destination
268+ 4 │ select (c).a from t;
269+ ╰╴ ─ 1. source
270+ " ) ;
271+ assert_snapshot ! ( goto( "
272+ create function f() returns int as 'select 1' language sql;
273+ select f($0);
274+ " ) , @r"
275+ ╭▸
276+ 2 │ create function f() returns int as 'select 1' language sql;
277+ │ ─ 2. destination
278+ 3 │ select f();
279+ ╰╴ ─ 1. source
280+ " ) ;
281+
282+ assert_snapshot ! ( goto( "
283+ with t as (select array[1,2,3]::int[] c)
284+ select c[$01] from t;
285+ " ) , @r"
286+ ╭▸
287+ 2 │ with t as (select array[1,2,3]::int[] c)
288+ │ ─ 2. destination
289+ 3 │ select c[1] from t;
290+ ╰╴ ─ 1. source
291+ " ) ;
292+
293+ assert_snapshot ! ( goto( "
294+ with t as (select array[1,2,3]::int[] c, 1 b)
295+ select c[b]$0 from t;
296+ " ) , @r"
297+ ╭▸
298+ 2 │ with t as (select array[1,2,3]::int[] c, 1 b)
299+ │ ─ 2. destination
300+ 3 │ select c[b] from t;
301+ ╰╴ ─ 1. source
302+ " ) ;
259303 }
260304
261305 #[ test]
0 commit comments