File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 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
2222
2323 # Generate a continuation prompt based on IEx prompt.
2424 # This is set as global configuration on app start.
25- @ compile { :no_warn_undefined , :prim_tty }
2625 def prompt ( prompt ) do
2726 case Enum . split_while ( prompt , & ( & 1 != ?( ) ) do
2827 # It is not the default Elixir shell, so we use the default prompt
2928 { _ , [ ] } ->
30- List . duplicate ( ?\s , max ( 0 , :prim_tty . npwcwidthstring ( prompt ) - 3 ) ) ++ ~c" .. "
29+ List . duplicate ( ?\s , max ( 0 , prompt_width ( prompt ) - 3 ) ) ++ ~c" .. "
3130
3231 { 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 )
3444 end
3545 end
3646
You can’t perform that action at this time.
0 commit comments