Skip to content

Commit 3cb3d41

Browse files
committed
Keep capture operator on container cursor to quoted
1 parent a3a081c commit 3cb3d41

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

lib/elixir/lib/code/fragment.ex

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ defmodule Code.Fragment do
33
This module provides conveniences for analyzing fragments of
44
textual code and extract available information whenever possible.
55
6-
Most of the functions in this module provide a best-effort
7-
and may not be accurate under all circumstances. Read each
8-
documentation for more information.
9-
106
This module should be considered experimental.
117
"""
128

lib/elixir/src/elixir_tokenizer.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1796,7 +1796,7 @@ prune_tokens([{OpType, _, _} | _] = Tokens, [], Terminators)
17961796
OpType =:= in_match_op; OpType =:= type_op; OpType =:= dual_op; OpType =:= mult_op;
17971797
OpType =:= power_op; OpType =:= concat_op; OpType =:= range_op; OpType =:= xor_op;
17981798
OpType =:= pipe_op; OpType =:= stab_op; OpType =:= when_op; OpType =:= assoc_op;
1799-
OpType =:= rel_op; OpType =:= ternary_op ->
1799+
OpType =:= rel_op; OpType =:= ternary_op; OpType =:= capture_op ->
18001800
{Tokens, Terminators};
18011801
%%% or we traverse until the end.
18021802
prune_tokens([_ | Tokens], Opener, Terminators) ->

lib/elixir/test/elixir/code_fragment_test.exs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,8 @@ defmodule CodeFragmentTest do
10981098

10991099
test "keeps operators" do
11001100
assert cc2q("1 + 2") == s2q("1 + __cursor__()")
1101+
assert cc2q("&foo") == s2q("&__cursor__()")
1102+
assert cc2q("&foo/") == s2q("&foo/__cursor__()")
11011103
end
11021104

11031105
test "keeps function calls without parens" do
@@ -1200,11 +1202,6 @@ defmodule CodeFragmentTest do
12001202
assert cc2q("(fn x, y -> x + y end") == s2q("(__cursor__())")
12011203
end
12021204

1203-
test "removes captures" do
1204-
assert cc2q("[& &1") == s2q("[__cursor__()]")
1205-
assert cc2q("[&(&1") == s2q("[__cursor__()]")
1206-
end
1207-
12081205
test "removes closed terminators" do
12091206
assert cc2q("foo([1, 2, 3]") == s2q("foo(__cursor__())")
12101207
assert cc2q("foo({1, 2, 3}") == s2q("foo(__cursor__())")

0 commit comments

Comments
 (0)