mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-18 17:35:55 +08:00
Fix intellisense crash when hovering over bitstring modifiers (#1917)
This commit is contained in:
parent
3ada5c9146
commit
8e4f3067da
2 changed files with 14 additions and 8 deletions
|
@ -393,21 +393,20 @@ defmodule Livebook.Intellisense do
|
|||
"""
|
||||
@spec get_details(String.t(), pos_integer(), context()) :: Runtime.details_response() | nil
|
||||
def get_details(line, column, context) do
|
||||
case IdentifierMatcher.locate_identifier(line, column, context) do
|
||||
%{matches: []} ->
|
||||
%{matches: matches, range: range} = IdentifierMatcher.locate_identifier(line, column, context)
|
||||
|
||||
case Enum.filter(matches, &include_in_details?/1) do
|
||||
[] ->
|
||||
nil
|
||||
|
||||
%{matches: matches, range: range} ->
|
||||
contents =
|
||||
matches
|
||||
|> Enum.filter(&include_in_details?/1)
|
||||
|> Enum.map(&format_details_item/1)
|
||||
|
||||
matches ->
|
||||
contents = Enum.map(matches, &format_details_item/1)
|
||||
%{range: range, contents: contents}
|
||||
end
|
||||
end
|
||||
|
||||
defp include_in_details?(%{kind: :function, from_default: true}), do: false
|
||||
defp include_in_details?(%{kind: :bitstring_modifier}), do: false
|
||||
defp include_in_details?(_), do: true
|
||||
|
||||
defp format_details_item(%{kind: :variable, name: name}), do: code(name)
|
||||
|
|
|
@ -1285,6 +1285,13 @@ defmodule Livebook.IntellisenseTest do
|
|||
assert to_string_fn =~ "Converts the argument to a string"
|
||||
end
|
||||
|
||||
test "returns nil for bitstring modifiers" do
|
||||
context = eval(do: nil)
|
||||
|
||||
assert nil == Intellisense.get_details("<<x :: integer>>", 6, context)
|
||||
assert nil == Intellisense.get_details("<<x :: integer>>", 10, context)
|
||||
end
|
||||
|
||||
test "includes full module name in the docs" do
|
||||
context = eval(do: nil)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue