diff options
author | José Valim <jose.valim@dashbit.co> | 2021-12-10 08:10:13 +0100 |
---|---|---|
committer | José Valim <jose.valim@dashbit.co> | 2021-12-10 09:27:45 +0100 |
commit | 99006eb081cc1cce2426c80732a20a9168d24473 (patch) | |
tree | 1fb8876705b915c606a10c8e13e66d208034a94c | |
parent | b13a9977d90c22ffce2aeaf1622b76789cadb2ff (diff) | |
download | elixir-99006eb081cc1cce2426c80732a20a9168d24473.tar.gz |
Do not cursor sigil after dot
-rw-r--r-- | lib/elixir/lib/code/fragment.ex | 10 | ||||
-rw-r--r-- | lib/elixir/test/elixir/code_fragment_test.exs | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/elixir/lib/code/fragment.ex b/lib/elixir/lib/code/fragment.ex index 365bb0d53..47dc99a90 100644 --- a/lib/elixir/lib/code/fragment.ex +++ b/lib/elixir/lib/code/fragment.ex @@ -383,8 +383,14 @@ defmodule Code.Fragment do {:none, 0} end - defp operator(_rest, count, '~', _call_op?) do - {{:sigil, ''}, count} + defp operator(rest, count, '~', call_op?) do + {rest, _} = strip_spaces(rest, count) + + if call_op? or match?([?. | rest] when rest == [] or hd(rest) != ?., rest) do + {:none, 0} + else + {{:sigil, ''}, count} + end end defp operator(rest, count, acc, _call_op?) do diff --git a/lib/elixir/test/elixir/code_fragment_test.exs b/lib/elixir/test/elixir/code_fragment_test.exs index 6dcf9066f..bc8d84e6a 100644 --- a/lib/elixir/test/elixir/code_fragment_test.exs +++ b/lib/elixir/test/elixir/code_fragment_test.exs @@ -215,6 +215,9 @@ defmodule CodeFragmentTest do assert CF.cursor_context("~R") == {:sigil, 'R'} assert CF.cursor_context("~R/") == :none assert CF.cursor_context("~R<") == :none + + assert CF.cursor_context("Foo.~") == :none + assert CF.cursor_context("Foo.~ ") == :none end test "module attribute" do |