mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-08 20:46:16 +08:00
Fix undefined function warning (#241)
This commit is contained in:
parent
c3a0b7c01d
commit
a2eb269cec
2 changed files with 11 additions and 1 deletions
2
.github/workflows/test.yaml
vendored
2
.github/workflows/test.yaml
vendored
|
@ -18,6 +18,8 @@ jobs:
|
||||||
run: mix deps.get
|
run: mix deps.get
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: mix format --check-formatted
|
run: mix format --check-formatted
|
||||||
|
- name: Check warnings
|
||||||
|
run: mix compile --warnings-as-errors
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: elixir --cookie "COOKIEFORTESTS" -S mix test
|
run: elixir --cookie "COOKIEFORTESTS" -S mix test
|
||||||
- name: Install Node
|
- name: Install Node
|
||||||
|
|
|
@ -676,7 +676,15 @@ defmodule Livebook.Completion do
|
||||||
def cursor_context(charlist, opts) when is_list(charlist) and is_list(opts) do
|
def cursor_context(charlist, opts) when is_list(charlist) and is_list(opts) do
|
||||||
chunked = Enum.chunk_by(charlist, &(&1 == ?\n))
|
chunked = Enum.chunk_by(charlist, &(&1 == ?\n))
|
||||||
|
|
||||||
case List.last(chunked, []) do
|
# TODO: Use List.last/2 on Elixir v1.12+
|
||||||
|
last =
|
||||||
|
if chunked == [] do
|
||||||
|
[]
|
||||||
|
else
|
||||||
|
List.last(chunked)
|
||||||
|
end
|
||||||
|
|
||||||
|
case last do
|
||||||
[?\n | _] -> do_cursor_context([], opts)
|
[?\n | _] -> do_cursor_context([], opts)
|
||||||
rest -> do_cursor_context(rest, opts)
|
rest -> do_cursor_context(rest, opts)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue