-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
repl: add a bunch of types to structs and methods #22377
Conversation
CI failure is a timeout. |
|
||
struct LatexCompletions <: CompletionProvider; end | ||
mutable struct REPLCompletionProvider <: CompletionProvider end | ||
mutable struct ShellCompletionProvider <: CompletionProvider end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need these two struct
s continue to be mutable? Above (around old lines 80-84) you changed a couple similar mutable struct
s to struct
s, so thought I might ask :).
Base.text_colors[:red], | ||
Base.text_colors[:yellow], | ||
false, false, false, envcolors | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Odd indentation? Perhaps better the )
simply terminate the preceding line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my preferred style for writing this kind of code. Clearly not universally agreed upon, but until we have an official style guide for this, I'm going to write it the way I prefer 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also happens to be my and Invenia's preferred style :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough :).
repl::LineEditREPL; | ||
hascolor::Bool = repl.hascolor, | ||
extra_repl_keymap::Vector{<:Dict} = Dict{Any,Any}[] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The )
placement seems a bit unusual here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my preferred style, although obviously not everyone agrees.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also happens to be my and Invenia's preferred style :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad to know I'm not the only one 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is excellent, each time I tried to hack around this files I got easily lost by the lack of type annotations. I'm not export here, but as long as the test passes, this LGTM, thanks!
terminal | ||
histprompt | ||
terminal::AbstractTerminal | ||
histprompt # ::HistoryPrompt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why comment the type annotation here? (similar question in other places, e.g. with CompletionProvider
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because that's the type in practice, but HistoryPrompt
doesn't exist yet when this is defined. The reverse dependency is unfortunate and something that should be fixed, but that kind of refactoring is beyond the scope of this PR.
|
||
struct LatexCompletions <: CompletionProvider; end | ||
mutable struct REPLCompletionProvider <: CompletionProvider end | ||
mutable struct ShellCompletionProvider <: CompletionProvider end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems you can remove the mutable
here as you did for other types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that – they have finalizers, so it doesn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok thanks
function setup_interface( | ||
repl::LineEditREPL; | ||
hascolor::Bool = repl.hascolor, | ||
extra_repl_keymap::Vector{<:Dict} = Dict{Any,Any}[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you mean ::Vector{<:Associative}
instead of ::Vector{<:Dict}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could do that, but in practice only Dicts get stuck in there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then why not Vector{Dict}
? The subtype operator on a concrete type looks confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see what you're saying. Yes, that makes sense, not sure what I was thinking here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's funny.
Pedantic question: do we say Dict
is concrete without its type parameters? (asDict != Dict{Any,Any}
- and if concrete Dict{Any,Any}
always finds its way here in practice, I suppose there may be a minor performance difference too).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I got confused, no 100% familiar yet with this {<:T}
notation ;-)
`stty sane` | ||
end,t.in_stream,t.out_stream,t.err_stream) | ||
run((raw ? `stty raw -echo onlcr -ocrnl opost` : `stty sane`), | ||
t.in_stream, t.out_stream, t.err_stream) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 :)
ccall(:jl_tty_set_mode, | ||
Int32, (Ptr{Void},Int32), | ||
t.in_stream.handle, raw) != -1 | ||
ccall(:jl_tty_set_mode, Int32, (Ptr{Void},Int32), t.in_stream.handle, raw) != -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space separating tuple arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Superficially lgtm! :) (Modulo minor comments.)
@@ -113,22 +118,17 @@ cmove_right(t::UnixTerminal, n) = write(t.out_stream, "$(CSI)$(n)C") | |||
cmove_left(t::UnixTerminal, n) = write(t.out_stream, "$(CSI)$(n)D") | |||
cmove_line_up(t::UnixTerminal, n) = (cmove_up(t, n); cmove_col(t, 1)) | |||
cmove_line_down(t::UnixTerminal, n) = (cmove_down(t, n); cmove_col(t, 1)) | |||
cmove_col(t::UnixTerminal, n) = (write(t.out_stream, '\r'); n > 1 && cmove_right(t, n - 1)) | |||
cmove_col(t::UnixTerminal, n) = (write(t.out_stream, '\r'); n > 1 && cmove_right(t, n-1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be consistent with the formatting in the rest of the file, which doesn't have spaces in small arithmetic expressions anywhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, thanks for clarifying
include("LineEdit.jl") | ||
include("REPLCompletions.jl") | ||
include("REPL.jl") | ||
include("repl/Terminals.jl") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using joinpath if possible may avoid mixed forward and backslashes in backtraces on windows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I finally understand why I see people use joinpath
in otherwise trivial cases! Wow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd kind of prefer if we used forward slashes for joinpath and everything else even on Windows but that might be unlikely. Most Windows programs can handle forward slashes in paths just fine, but maybe not all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably introduce Path types and have path"repl/Terminals.jl"
produce whatever the native path syntax is. That would also allow path"C:\some\where"
to work on Windows systems without double backslashes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches the style of all other includes in sysimg.jl
, so I'm going to leave it. Normalizing path names to included files would probably make sense. I suspect this is not simply a style issue since joinpath
is not defined when much of this file runs.
eb5bf5e
to
b3e6589
Compare
Failure is timeout and #22353, not related. |
@@ -1057,7 +1062,7 @@ function run_frontend(repl::StreamREPL, backend::REPLBackendRef) | |||
dopushdisplay && popdisplay(d) | |||
end | |||
|
|||
function start_repl_server(port) | |||
function start_repl_server(port::Int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
::Integer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an internal function and if the value is too large, this won't work anyway, so Int is ok.
This finishes the work started in #22377
This finishes the work started in #22377
This finishes the work started in JuliaLang#22377
No description provided.