Fix undefined function warning (#241)

This commit is contained in:
Akash Hiremath 2021-04-26 12:29:46 +05:30 committed by GitHub
parent c3a0b7c01d
commit a2eb269cec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -18,6 +18,8 @@ jobs:
run: mix deps.get
- name: Check formatting
run: mix format --check-formatted
- name: Check warnings
run: mix compile --warnings-as-errors
- name: Run tests
run: elixir --cookie "COOKIEFORTESTS" -S mix test
- name: Install Node

View file

@ -676,7 +676,15 @@ defmodule Livebook.Completion do
def cursor_context(charlist, opts) when is_list(charlist) and is_list(opts) do
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)
rest -> do_cursor_context(rest, opts)
end