-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e11732
commit 574090e
Showing
3 changed files
with
147 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
defmodule SourcerorTest.CursorSupport do | ||
Check warning on line 1 in test/support/cursor_support.ex GitHub Actions / ci (1.15.5, 26, true, true, true, true)
|
||
@doc """ | ||
Extracts the `[:line, :column]` position of the first `|` character found in the text. | ||
Returns `{position, text}`. | ||
""" | ||
def pop_cursor(text) do | ||
case String.split(text, "|", parts: 2) do | ||
[prefix, suffix] -> | ||
lines = String.split(prefix, "\n") | ||
cursor_line_length = lines |> List.last() |> String.length() | ||
position = [line: length(lines), column: cursor_line_length + 1] | ||
{position, prefix <> suffix} | ||
|
||
_ -> | ||
raise ArgumentError, "Could not find cursor in:\n\n#{text}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters