-
Notifications
You must be signed in to change notification settings - Fork 337
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
improvement: Don't sent text on didSave #7015
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -884,9 +884,9 @@ abstract class MetalsLspService( | |||||||||
): CompletableFuture[Unit] = { | ||||||||||
val path = params.getTextDocument.getUri.toAbsolutePath | ||||||||||
savedFiles.add(path) | ||||||||||
// read file from disk, we only remove files from buffers on didClose. | ||||||||||
val text = path.toInput.text | ||||||||||
buffers.put(path, text) | ||||||||||
if (!buffers.contains(path)) { | ||||||||||
buffers.put(path, path.toInput.text) | ||||||||||
} | ||||||||||
Comment on lines
+887
to
+889
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think that Also, a question to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are very right. We want and we should use text document version simply nobody found the time to do it. I thought there was an issue for that but I could not find it now, here is a connected issue: #1665. |
||||||||||
Future | ||||||||||
.sequence( | ||||||||||
List( | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,8 @@ abstract class BaseRenameLspSuite(name: String) extends BaseLspSuite(name) { | |
// possible breaking changes for testing | ||
_ <- Future.sequence { | ||
openedFiles.map { file => | ||
server.didSave(file) { code => breakingChange(code) } | ||
server.didChange(file) { code => breakingChange(code) } | ||
server.didSave(file)(identity) | ||
} | ||
} | ||
_ = if (!expectedError) assertNoDiagnostics() | ||
|
@@ -124,9 +125,12 @@ abstract class BaseRenameLspSuite(name: String) extends BaseLspSuite(name) { | |
Future | ||
.sequence { | ||
files.map { case (file, code) => | ||
server.didSave(file)(_ => | ||
code.replaceAll(allMarkersRegex, "") | ||
) | ||
for { | ||
_ <- server.didChange(file)(_ => | ||
code.replaceAll(allMarkersRegex, "") | ||
) | ||
_ <- server.didSave(file)(identity) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should do either of two:
|
||
} yield () | ||
}.toList | ||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,12 +285,14 @@ abstract class BaseWorksheetLspSuite( | |
_ <- server.didOpen("a/src/main/scala/Main.worksheet.sc") | ||
_ <- cancelled.future | ||
_ = client.onWorkDoneProgressStart = (_, _) => {} | ||
_ <- server.didSave("a/src/main/scala/Main.worksheet.sc")( | ||
_ <- server.didChange("a/src/main/scala/Main.worksheet.sc")( | ||
_.replace("Stream", "// Stream") | ||
) | ||
_ <- server.didSave("a/src/main/scala/Main.worksheet.sc")( | ||
_ <- server.didSave("a/src/main/scala/Main.worksheet.sc")(identity) | ||
_ <- server.didChange("a/src/main/scala/Main.worksheet.sc")( | ||
_.replace("42", "43") | ||
) | ||
_ <- server.didSave("a/src/main/scala/Main.worksheet.sc")(identity) | ||
_ = assertNoDiff( | ||
client.syntheticDecorations, | ||
"""| | ||
|
@@ -469,9 +471,11 @@ abstract class BaseWorksheetLspSuite( | |
|a.Util.increase(1) // : Int = 2 | ||
|""".stripMargin, | ||
) | ||
_ <- server.didSave("a/src/main/scala/a/Util.scala")( | ||
_ <- server.didChange("a/src/main/scala/a/Util.scala")( | ||
_.replace("n + 1", "n + 2") | ||
) | ||
_ <- server.didSave("a/src/main/scala/a/Util.scala")(identity) | ||
_ <- server.didFocus("a/src/main/scala/a/Main.worksheet.sc") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should ever need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's just focus switched to Util.scala and the worksheet doesn't evaluate. This will work in VS Code, thoguh wonder what happens if did focus is not supported |
||
_ <- server.didSave("a/src/main/scala/a/Main.worksheet.sc")(identity) | ||
_ = assertNoDiff( | ||
client.workspaceDecorations("a/src/main/scala/a/Main.worksheet.sc"), | ||
|
@@ -782,12 +786,13 @@ abstract class BaseWorksheetLspSuite( | |
) | ||
), | ||
) | ||
_ <- server.didSave("a/src/main/scala/foo/Main.worksheet.sc")( | ||
_ <- server.didChange("a/src/main/scala/foo/Main.worksheet.sc")( | ||
_.replace( | ||
"Hi(1, 2, 3)", | ||
"Hi(7, 8, 9)", | ||
) | ||
) | ||
_ <- server.didSave("a/src/main/scala/foo/Main.worksheet.sc")(identity) | ||
export = server.exportEvaluation( | ||
"a/src/main/scala/foo/Main.worksheet.sc" | ||
) | ||
|
@@ -951,9 +956,10 @@ abstract class BaseWorksheetLspSuite( | |
Nil, | ||
) | ||
_ <- client.applyCodeAction(0, codeActions, server) | ||
_ <- server.didSave(path) { _ => | ||
_ <- server.didChange(path) { _ => | ||
server.bufferContents(path) | ||
} | ||
_ <- server.didSave(path)(identity) | ||
// Assert if indentation is correct. See `AutoImports.renderImport` | ||
_ = assertNoDiff( | ||
server.bufferContents(path), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -785,6 +785,7 @@ final case class TestingServer( | |
val abspath = toPath(filename) | ||
val oldText = abspath.toInputFromBuffers(buffers).text | ||
val newText = fn(oldText) | ||
buffers.put(abspath, newText) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? |
||
didChange(filename, newText) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem necessary and for large files might actually be problematic.