Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ New language features
- `α΅…` (U+U+1D45), `α΅‹` (U+1D4B), `αΆ²` (U+1DB2), `Λ±` (U+02F1), `Λ²` (U+02F2), and `β‚”` (U+2094) can now also be used as
operator suffixes, accessible as `\^alpha`, `\^epsilon`, `\^ltphi`, `\_<`, `\_>`, and `\_schwa` at the REPL
([#60285]).
- Combining emoji sequences can now be input with the syntax `\:man:woman:girl:boy:` to produce `πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦`
("\u1F468\u200D\u1F469\u200D\u1F467\u200d\u1F466"). The zero width joiner on its own is `\zwj`.
- Latex expansions can now be searched like `\?search<tab>` to show all symbols *containing* rather than starting
with the search string. Queries are separated by question marks, eg `\?arrow?up<tab>` will show the various up arrows
- The `@label` macro can now create labeled blocks that can be exited early with `break name [value]`. Use
`@label name expr` for named blocks or `@label expr` for anonymous blocks. Anonymous `@label` blocks
participate in the default break scope: a plain `break` or `break _` exits the innermost breakable scope,
Expand Down
24 changes: 19 additions & 5 deletions stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -872,15 +872,29 @@ function bslash_completions(string::String, pos::Int, hint::Bool=false)
sup = map(c -> superscripts[c], s[3:end])
return (true, (Completion[BslashCompletion(sup)], slashpos:pos, true))
end
emoji = get(emoji_symbols, s, "")
if !isempty(emoji)
emoji = get.(Ref(emoji_symbols), "\\:" .* split(s, ':')[2:end-1] .* ':', "")
if !isempty(emoji) && all(!isempty, emoji) && length(s)>3 && s[2] == s[end] == ':'
emoji = join(emoji, '\u200d') # combine multiple emoji with zwj
return (true, (Completion[BslashCompletion(emoji)], slashpos:pos, true))
end
# return possible matches; these cannot be mixed with regular
# Julian completions as only latex / emoji symbols contain the leading \
symbol_dict = startswith(s, "\\:") ? emoji_symbols : latex_symbols
namelist = Iterators.filter(k -> startswith(k, s), keys(symbol_dict))
completions = Completion[BslashCompletion(name, "$(symbol_dict[name]) $name") for name in sort!(collect(namelist))]
comps = if startswith(s, "\\:")
names = Iterators.filter(keys(emoji_symbols)) do keyname
last_part = split(s, ':')[end]
startswith(keyname, "\\:" * last_part)
end |> collect |> sort!
Iterators.zip(
join(emoji, '\u200d') * '\u200d'^sign(length(emoji)) .* get.(Ref(emoji_symbols), names, ""),
s[1:findlast(':', s)] .* getindex.(names, (:).(3, length.(names)))
)
else
filt = startswith(s, "\\?") ? k -> all(contains.(k, split(s, '?')[2:end])) :
k -> startswith(k, s)
names = Iterators.filter(filt, keys(latex_symbols)) |> collect |> sort!
Iterators.zip(get.(Ref(latex_symbols), names, ""), names)
end
completions = Completion[BslashCompletion(name, "$symbol $name") for (symbol, name) in comps]
return (true, (completions, slashpos:pos, true))
end
return (false, (Completion[], 1:0, false))
Expand Down
27 changes: 27 additions & 0 deletions stdlib/REPL/src/docview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -540,26 +540,53 @@ function repl_latex(io::IO, s0::String)
if length(latex_symbol) == 3 && latex_symbol[2] in ('^','_')
# coalesce runs of sub/superscripts
if state != latex_symbol[2]
'e' == state && print(io, "<tab>\\zwj")
'\0' != state && print(io, "<tab>")
print(io, latex_symbol[1:2])
state = latex_symbol[2]
end
print(io, latex_symbol[3])
elseif latex_symbol[2] == ':'
# coalesce zwj emoji sequences
if state in ('^', '_', ':')
print(io, "<tab>")
print(io, latex_symbol)
elseif state == 'e'
print(io, latex_symbol[3:end])
else # state == '\0'
print(io, latex_symbol)
end
state = ':'
elseif latex_symbol == "\\zwj"
if state in ('^', '_')
print(io, "<tab>\\zwj<tab>")
state = '\0'
elseif state == 'e'
print(io, "<tab>\\zwj<tab>\\zwj<tab>")
state = '\0'
elseif state == ':'
state = 'e'
else # state == '\0'
print(io, "\\zwj<tab>")
end
else
'e' == state && print(io, "<tab>\\zwj")
if '\0' != state
print(io, "<tab>")
state = '\0'
end
print(io, latex_symbol, "<tab>")
end
else
'e' == state && print(io, "<tab>\\zwj")
if '\0' != state
print(io, "<tab>")
state = '\0'
end
print(io, c)
end
end
'e' == state && print(io, "<tab>\\zwj")
'\0' != state && print(io, "<tab>")
end
println(io, '\n')
Expand Down
1 change: 1 addition & 0 deletions stdlib/REPL/src/latex_symbols.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const latex_symbols = Dict(

# manual additions:

"\\zwj" => "\u200D",
"\\sqrt" => "\u221A",
"\\cbrt" => "\u221B",
"\\female" => "♀",
Expand Down
9 changes: 9 additions & 0 deletions stdlib/REPL/test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,15 @@ let s = "Ξ±\\:koala:"
@test length(c) == 1
end

# test combining emoji completion
let s = "\\:man:woman:girl:boy:"
c, r = test_bslashcomplete(s)
@test c[1].completion == "πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦"
@test c[1].name == "πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦"
@test r == 1:sizeof(s)
@test length(c) == 1
end

# test latex symbol completions in strings should not work when there
# is a backslash in front of `\alpha` because it interferes with path completion on windows
let s = "cd(\"path_to_an_empty_folder_should_not_complete_latex\\\\\\alpha"
Expand Down
Loading