Skip to content

Commit

Permalink
fix #769
Browse files Browse the repository at this point in the history
  • Loading branch information
domluna committed Oct 27, 2023
1 parent 447c38e commit 009cac0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/fst.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1179,3 +1179,7 @@ Checks if the binary operation is a dot operation (e.g. `x.y`, `x..z`, `x...z`).
function is_dot_op(x::CSTParser.EXPR)
op_kind(x) in (Tokens.DDDOT, Tokens.DDOT, Tokens.DDOTS)
end

function is_isa(x::CSTParser.EXPR)
CSTParser.isoperator(x) && x.val == "isa"
end
2 changes: 1 addition & 1 deletion src/styles/blue/pretty.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function p_binaryopcall(
add_node!(t, Whitespace(1), s)
add_node!(t, pretty(style, op, s), s, join_lines = true)
nest ? add_node!(t, Placeholder(1), s) : add_node!(t, Whitespace(1), s)
elseif !(CSTParser.is_in(op) || CSTParser.is_elof(op)) && (
elseif !(CSTParser.is_in(op) || CSTParser.is_elof(op) || is_isa(op)) && (
nospace || (
!CSTParser.is_anon_func(op) && precedence(op) in (
CSTParser.RationalOp,
Expand Down
2 changes: 1 addition & 1 deletion src/styles/default/pretty.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ function p_binaryopcall(
add_node!(t, Whitespace(1), s)
add_node!(t, pretty(style, op, s), s, join_lines = true)
nest ? add_node!(t, Placeholder(1), s) : add_node!(t, Whitespace(1), s)
elseif !(CSTParser.is_in(op) || CSTParser.is_elof(op)) && (
elseif !(CSTParser.is_in(op) || CSTParser.is_elof(op) || is_isa(op)) && (
nospace || (
!CSTParser.is_anon_func(op) &&
precedence(op) in (CSTParser.PowerOp, CSTParser.DeclarationOp, CSTParser.DotOp)
Expand Down
2 changes: 1 addition & 1 deletion src/styles/sciml/pretty.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function p_macrocall(ys::SciMLStyle, cst::CSTParser.EXPR, s::State)
#
# No:
# `@parameters a = a b = b`
n = pretty(style, a, s, nospace = nospace)
n = pretty(style, a, s; nospace = nospace)
if CSTParser.ismacroname(a)
add_node!(t, n, s, join_lines = true)
if length(args) > 0
Expand Down
7 changes: 7 additions & 0 deletions test/issues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1763,4 +1763,11 @@
s1 = format_text(s, MinimalStyle())
@test format_text(s1, MinimalStyle()) == s
end

@testset "769" begin
s = raw"""
@assert x isa Tuple \"msg\"
"""
@test format_text(s, SciMLStyle()) == s
end
end

0 comments on commit 009cac0

Please sign in to comment.