forked from lem-project/lem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: scala-mode calc-indent-function (lem-project#1770)
I attached a screen record of the bug in scala-mode calc-indent-function. lem-js-node::js-calc-indent it breaks the indentes in some cases. I tried to fix it in this PR.
- Loading branch information
Showing
4 changed files
with
148 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
object LemScalaIndent { | ||
def main(args: Array[String]): Unit = { | ||
for (i <- 0 until 100) { | ||
Option(i) | ||
.map(_ + 1) | ||
.map(_ % 2) | ||
|
||
val oneTwo: String = { | ||
val one = "one" | ||
val two = "two" | ||
s"$one$two" | ||
} | ||
|
||
trait Human[T] { | ||
val age: Int | ||
} | ||
|
||
trait Greeter { | ||
def sayHello: Unit | ||
} | ||
|
||
case class Person( | ||
val name: String, | ||
surname: String, | ||
override val age: Int | ||
) extends Human[Person] | ||
with Greeter { | ||
override def sayHello: Unit = println(s"Hello, I'm $name! Nice to meet you") | ||
} | ||
|
||
val person = Person( | ||
name = "vasya", | ||
surname = "pupkin", | ||
age = 24 | ||
) | ||
|
||
person match { | ||
case Person(name, surname, age) => | ||
println(s"Person name: $name surname: $surname") | ||
case _ => | ||
throw new RuntimeException("Unrecognizable person") | ||
} | ||
|
||
if (person.name == "vasya") { | ||
println("Vasya is hear") | ||
} else { | ||
println("Vasya is lost") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
(defpackage :lem-tests/scala-mode | ||
(:use :cl | ||
:rove | ||
:lem-tests/utilities)) | ||
(in-package :lem-tests/scala-mode) | ||
|
||
(deftest scala-indent-region | ||
(with-testing-buffer (buffer (lem:find-file-buffer (sample-file "LemScalaIndent.scala"))) | ||
(testing "Test indent region" | ||
(let ((before (lem:buffer-text buffer)) | ||
(after) | ||
(is-correct)) | ||
(lem:indent-current-buffer) | ||
(setq after (lem:buffer-text buffer)) | ||
(setq is-correct (string= before after)) | ||
(ok is-correct | ||
(if is-correct | ||
"Indent is correct" | ||
(diff-text before after))))))) |