-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
Description
e.g. following code when indent with emacs builtin ruby-mode (without LSP enabled), it will indent like this:
# test.rb, it correct.
result = (42..47).to_a # (1) => [42, 43, 44, 45, 46, 47]
.sort { |n, m| m <=> n } # (2) => [47, 46, 45, 44, 43, 42]
.reject { |n| n.odd? } # (3) => [46, 44, 42]
.map { |n| n * n } # (4) => [2116, 1936, 1764]
.select { |n| n % 4 == 0 } # (5) => [2116, 1936, 1764]
.tap { |arr| puts "#{arr.inspect}" } # (6) => [2116, 1936, 1764]
.sort! # (7) => [1764, 1936, 2116]
.any? { |num| num > 2000 } # (8) => truebut, if switch to crystal-mode, it indent like this:
# test1.cr, indent not correct
result = (42..47).to_a # (1) => [42, 43, 44, 45, 46, 47]
.sort { |n, m| m <=> n } # (2) => [47, 46, 45, 44, 43, 42]
.reject { |n| n.odd? } # (3) => [46, 44, 42]
.map { |n| n * n } # (4) => [2116, 1936, 1764]
.select { |n| n % 4 == 0 } # (5) => [2116, 1936, 1764]
.tap { |arr| puts "#{arr.inspect}" } # (6) => [2116, 1936, 1764]
.sort! # (7) => [1764, 1936, 2116]
.any? { |num| num > 2000 } # (8) => true
But, if remove the those comment from line ending, it indent correct again.
# test2.cr, indent correct.
result = (42..47).to_a
.sort { |n, m| m <=> n }
.reject { |n| n.odd? }
.map { |n| n * n }
.select { |n| n % 4 == 0 }
.tap { |arr| puts "#{arr.inspect}" }
.sort!
.any? { |num| num > 2000 }