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

improvement: Don't sent text on didSave #7015

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tgodzik
Copy link
Contributor

@tgodzik tgodzik commented Dec 9, 2024

Previously, we would have clients send us full text on didSave, which was never used.

Now, we removed that option.

I also removed reading the file from disk to buffers since that file should already be up to date form didChanged

@@ -884,9 +884,6 @@ 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
Copy link
Contributor Author

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.

@tgodzik tgodzik force-pushed the did-save branch 4 times, most recently from 9fd01d9 to af3b81b Compare December 10, 2024 16:22
@tgodzik tgodzik requested a review from kasiaMarek December 12, 2024 14:09
@tgodzik tgodzik marked this pull request as ready for review December 12, 2024 14:09
_ <- server.didChange(file)(_ =>
code.replaceAll(allMarkersRegex, "")
)
_ <- server.didSave(file)(identity)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should do either of two:

  • remove change function from server.didChange (it will always de identity)
  • have server.didSave with the function send first didChange and only later didSave.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have server.didSave with the function send first didChange and only later didSave.

That proved to be complicated and broke a few things, I will change to didSave always doing identity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove fn from didSave to make it explicit that it doesn't actually send anything. And also this wasn't simulating correctly how the editor would work

_.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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should ever need didFocus, since it may not be supported, right?

Copy link
Contributor Author

@tgodzik tgodzik Dec 13, 2024

Choose a reason for hiding this comment

The 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, though wonder what happens if did focus is not supported

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We weren't actually updating the buffers

Previously, we would have clients send us full text on didSave, which was never used.

Now, we removed that option.

I also removed reading the file from disk to buffers since that file should already be up to date form didChanged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants