Skip to content

Commit

Permalink
Add is_triple_string utility function
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Aug 1, 2024
1 parent d239be2 commit d82a879
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/chisels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ const TAG_LINE_CONT = UInt32(1) << 31
const TAG_TRAILING_COMMA = TagType(1) << 4

function add_tag(node::Node, tag::TagType)
if kind(node) !== K"parameters"
@assert is_leaf(node)
end
return Node(head(node), span(node), node.kids, node.tags | tag)
end

Expand Down Expand Up @@ -540,6 +537,11 @@ function contains_multiline_triple_string(ctx, node::Node)
return false
end

function is_triple_string(node)
return kind(node) in KSet"string cmdstring" &&
JuliaSyntax.has_flags(node, JuliaSyntax.TRIPLE_STRING_FLAG)
end

##########################
# Utilities for IOBuffer #
##########################
Expand Down
5 changes: 4 additions & 1 deletion src/runestone.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2074,6 +2074,9 @@ function indent_call(ctx::Context, node::Node)
end


# TODO: I feel like this function can be removed. The use in `indent_assignment` can be
# replaced with `continue_all_newlines` but the use in `indent_op_call` might have to be
# tweaked slightly.
function indent_newlines_between_indices(
ctx::Context, node::Node, open_idx::Int, close_idx::Int;
indent_closing_token::Bool = false,
Expand Down Expand Up @@ -2759,7 +2762,7 @@ function insert_delete_mark_newlines(ctx::Context, node::Node)
end

function indent_multiline_strings(ctx::Context, node::Node)
if !(kind(node) in KSet"string cmdstring" && JuliaSyntax.has_flags(node, JuliaSyntax.TRIPLE_STRING_FLAG))
if !is_triple_string(node)
return nothing
end
triplekind = kind(node) === K"string" ? K"\"\"\"" : K"```"
Expand Down

0 comments on commit d82a879

Please sign in to comment.