Skip to content
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

Indent right side expressions in assignments where the left side includes a type declaration #15429

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion lib/markd/src/markd/options.cr
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module Markd
@source_pos = false,
@safe = false,
@prettyprint = false,
@base_url = nil
@base_url = nil,
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/markd/src/markd/renderers/html_renderer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ module Markd
@last_output = ">"
end

private def tag(name : String, attrs = nil)
private def tag(name : String, attrs = nil, &)
tag(name, attrs)
yield
tag(name, end_tag: true)
Expand Down
2 changes: 1 addition & 1 deletion lib/markd/src/markd/utils.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require "json"

module Markd
module Utils
def self.timer(label : String, measure_time? : Bool)
def self.timer(label : String, measure_time? : Bool, &)
return yield unless measure_time?

start_time = Time.utc
Expand Down
3 changes: 3 additions & 0 deletions spec/compiler/formatter/formatter_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,9 @@ describe Crystal::Formatter do
assert_format "a = # foo\n bar(1)"
assert_format "a = \\\n # foo\n bar(1)"
assert_format "a = \\\n # foo\n nil"
assert_format "a : String = if 1\n\"One\"\nelse\"Zero\"\nend", "a : String = if 1\n \"One\"\n else\n \"Zero\"\n end"
assert_format "a : String = case 1\nwhen 2\n3\nend", "a : String = case 1\n when 2\n 3\n end"
assert_format "a : String = \nif 1\n1\nelse\n2\nend", "a : String =\n if 1\n 1\n else\n 2\n end"

assert_format %(require "foo"), %(require "foo")

Expand Down
6 changes: 3 additions & 3 deletions src/compiler/crystal/tools/formatter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3649,9 +3649,9 @@ module Crystal
if value = node.value
skip_space
check :OP_EQ
next_token_skip_space_or_newline
write " = "
accept value
next_token_skip_space
write " ="
accept_assign_value_after_equals value
end
false
end
Expand Down
Loading