File tree 1 file changed +13
-3
lines changed
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -22,15 +22,25 @@ defmodule IEx.Config do
22
22
23
23
# Generate a continuation prompt based on IEx prompt.
24
24
# This is set as global configuration on app start.
25
- @ compile { :no_warn_undefined , :prim_tty }
26
25
def prompt ( prompt ) do
27
26
case Enum . split_while ( prompt , & ( & 1 != ?( ) ) do
28
27
# It is not the default Elixir shell, so we use the default prompt
29
28
{ _ , [ ] } ->
30
- List . duplicate ( ?\s , max ( 0 , :prim_tty . npwcwidthstring ( prompt ) - 3 ) ) ++ ~c" .. "
29
+ List . duplicate ( ?\s , max ( 0 , prompt_width ( prompt ) - 3 ) ) ++ ~c" .. "
31
30
32
31
{ left , right } ->
33
- List . duplicate ( ?. , :prim_tty . npwcwidthstring ( left ) ) ++ right
32
+ List . duplicate ( ?. , prompt_width ( left ) ) ++ right
33
+ end
34
+ end
35
+
36
+ # TODO: Remove this when we require Erlang/OTP 27+
37
+ @ compile { :no_warn_undefined , :prim_tty }
38
+ @ compile { :no_warn_undefined , :shell }
39
+ defp prompt_width ( prompt ) do
40
+ if function_exported? ( :prim_tty , :npwcwidthstring , 1 ) do
41
+ :prim_tty . npwcwidthstring ( prompt )
42
+ else
43
+ :shell . prompt_width ( prompt )
34
44
end
35
45
end
36
46
You can’t perform that action at this time.
0 commit comments