Skip to content

Commit fae8f09

Browse files
committed
Handle string function name parameter
1 parent ce2cd59 commit fae8f09

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

apps/language_server/lib/language_server/experimental/code_mod/extract_function.ex

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ defmodule ElixirLS.LanguageServer.Experimental.CodeMod.ExtractFunction do
99
Return zipper containing AST with extracted function.
1010
"""
1111
def extract_function(zipper, start_line, end_line, function_name) do
12+
function_name =
13+
if is_binary(function_name), do: String.to_atom(function_name), else: function_name
14+
1215
{quoted_after_extract, acc} = extract_lines(zipper, start_line, end_line, function_name)
1316
if Enum.empty?(acc.lines) do
1417
{:error, :not_extractable}

apps/language_server/test/experimental/code_mod/extract_function_test.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ defmodule ElixirLS.LanguageServer.Experimental.CodeMod.ExtractFunctionTest do
3737
describe "extract_function" do
3838
@tag no: 1
3939
test "extract one line to function", %{quoted: quoted} do
40-
zipper = ExtractFunction.extract_function(Z.zip(quoted), 3, 3, :bar)
40+
zipper = ExtractFunction.extract_function(Z.zip(quoted), 3, 3, "bar")
4141
source = Sourceror.to_string(zipper)
4242

4343
assert [

0 commit comments

Comments
 (0)