Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into eph/limit-repl
Browse files Browse the repository at this point in the history
  • Loading branch information
ericphanson committed Jul 24, 2024
2 parents 1add163 + a3cbb18 commit 8a48d1c
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 11 deletions.
2 changes: 1 addition & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Multi-threading changes
-----------------------

* `Threads.@threads` now supports the `:greedy` scheduler, intended for non-uniform workloads ([#52096]).
* A new exported struct `Lockable{T, L<:AbstractLock}` makes it easy to bundle a resource and its lock together ([#52898]).
* A new public (but unexported) struct `Base.Lockable{T, L<:AbstractLock}` makes it easy to bundle a resource and its lock together ([#52898]).

Build system changes
--------------------
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ New library features
* `tempname` can now take a suffix string to allow the file name to include a suffix and include that suffix in
the uniquing checking ([#53474])
* `RegexMatch` objects can now be used to construct `NamedTuple`s and `Dict`s ([#50988])
* `Lockable` is now exported ([#54595])

Standard library changes
------------------------
Expand Down
1 change: 1 addition & 0 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export
IOBuffer,
IOStream,
LinRange,
Lockable,
Irrational,
LazyString,
Matrix,
Expand Down
2 changes: 1 addition & 1 deletion base/gcutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ WeakRef
# Used by `Base.finalizer` to validate mutability of an object being finalized.
function _check_mutable(@nospecialize(o)) @noinline
if !ismutable(o)
error("objects of type ", typeof(o), " cannot be finalized")
error("objects of type ", typeof(o), " cannot be finalized because they are not mutable")
end
end

Expand Down
16 changes: 12 additions & 4 deletions base/strings/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,20 @@ function join(io::IO, iterator, delim="")
end

function _join_preserve_annotations(iterator, args...)
if _isannotated(eltype(iterator)) || any(_isannotated, args)
if isconcretetype(eltype(iterator)) && !_isannotated(eltype(iterator)) && !any(_isannotated, args)
sprint(join, iterator, args...)
else
io = AnnotatedIOBuffer()
join(io, iterator, args...)
read(seekstart(io), AnnotatedString{String})
else
sprint(join, iterator, args...)
# If we know (from compile time information, or dynamically in the case
# of iterators with a non-concrete eltype), that the result is annotated
# in nature, we extract an `AnnotatedString`, otherwise we just extract
# a plain `String` from `io`.
if isconcretetype(eltype(iterator)) || !isempty(io.annotations)
read(seekstart(io), AnnotatedString{String})
else
String(take!(io.io))
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion doc/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
version = "1.11.0"

[[deps.REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "StyledStrings", "Unicode"]
deps = ["InteractiveUtils", "JuliaSyntaxHighlighting", "Markdown", "Sockets", "StyledStrings", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
version = "1.11.0"

Expand Down
4 changes: 4 additions & 0 deletions doc/src/base/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ where
;
=
?:
.=
.
->
::
```

## Standard Modules
Expand Down
3 changes: 3 additions & 0 deletions src/crc32c.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ JL_DLLEXPORT uint32_t jl_crc32c(uint32_t crc, const char *buf, size_t len)
return crc32c_sse42(crc, buf, len);
}
# else
#if defined(JL_CRC32C_USE_IFUNC) && defined(_COMPILER_CLANG_)
JL_UNUSED
#endif
static crc32c_func_t crc32c_dispatch(void)
{
// When used in ifunc, we cannot call external functions (i.e. jl_cpuid)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
version = "1.11.0"

[[deps.REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "StyledStrings", "Unicode"]
deps = ["InteractiveUtils", "JuliaSyntaxHighlighting", "Markdown", "Sockets", "StyledStrings", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
version = "1.11.0"

Expand Down
1 change: 1 addition & 0 deletions stdlib/REPL/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "1.11.0"

[deps]
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
JuliaSyntaxHighlighting = "dc6e5ff7-fb65-4e79-a425-ec3bc9c03011"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
StyledStrings = "f489334b-da3d-4c2e-b8f0-e476e12c162b"
Expand Down
21 changes: 20 additions & 1 deletion stdlib/REPL/src/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,26 @@ function edit_move_right(buf::IOBuffer)
end
return false
end
edit_move_right(s::PromptState) = edit_move_right(s.input_buffer) ? refresh_line(s) : false
function edit_move_right(m::MIState)
s = state(m)
buf = s.input_buffer
if edit_move_right(s.input_buffer)
refresh_line(s)
return true
else
completions, partial, should_complete = complete_line(s.p.complete, s, m.active_module)
if should_complete && eof(buf) && length(completions) == 1 && length(partial) > 1
# Replace word by completion
prev_pos = position(s)
push_undo(s)
edit_splice!(s, (prev_pos - sizeof(partial)) => prev_pos, completions[1])
refresh_line(state(s))
return true
else
return false
end
end
end

function edit_move_word_right(s::PromptState)
if !eof(s.input_buffer)
Expand Down
11 changes: 10 additions & 1 deletion stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ function __init__()
end

using Base.Meta, Sockets, StyledStrings
using JuliaSyntaxHighlighting
import InteractiveUtils

export
Expand Down Expand Up @@ -551,7 +552,8 @@ function show_limited(io::IO, mime::MIME, x)
# We unpack `IOContext`s, since we will pass the properties on the outside.
inner = io isa IOContext ? io.io : io
wrapped_limiter = IOContext(LimitIO(inner, SHOW_MAXIMUM_BYTES), Base.ioproperties(io))
show(wrapped_limiter, mime, x)
# `show_repl` to allow the hook with special syntax highlighting
show_repl(wrapped_limiter, mime, x)
catch e
e isa LimitIOException || rethrow()
printstyled(io, "…[printing stopped after displaying $(Base.format_bytes(e.maxbytes))]"; color=:light_yellow, bold=true)
Expand Down Expand Up @@ -579,8 +581,15 @@ function display(d::REPLDisplay, mime::MIME"text/plain", x)
end
return nothing
end

display(d::REPLDisplay, x) = display(d, MIME("text/plain"), x)

show_repl(io::IO, mime::MIME"text/plain", x) = show(io, mime, x)

show_repl(io::IO, ::MIME"text/plain", ex::Expr) =
print(io, JuliaSyntaxHighlighting.highlight(
sprint(show, ex, context=IOContext(io, :color => false))))

function print_response(repl::AbstractREPL, response, show_value::Bool, have_color::Bool)
repl.waserror = response[2]
with_repl_linfo(repl) do io
Expand Down
2 changes: 1 addition & 1 deletion test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ end
# Lockable{T, L<:AbstractLock}
using Base: Lockable
let
@test_broken Base.isexported(Base, :Lockable)
@test Base.isexported(Base, :Lockable)
lockable = Lockable(Dict("foo" => "hello"), ReentrantLock())
# note field access is non-public
@test lockable.value["foo"] == "hello"
Expand Down
2 changes: 2 additions & 0 deletions test/strings/annotated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ end
[(1:4, :label => 5),
(5:5, :label => 2),
(6:9, :label => 5)])
@test join((String(str1), str1), ' ') ==
Base.AnnotatedString("test test", [(6:9, :label => 5)])
@test repeat(str1, 2) == Base.AnnotatedString("testtest", [(1:8, :label => 5)])
@test repeat(str2, 2) == Base.AnnotatedString("casecase", [(2:3, :label => "oomph"),
(6:7, :label => "oomph")])
Expand Down

0 comments on commit 8a48d1c

Please sign in to comment.