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

While find/replacing in VSCode across many files formatting save takes a long time and bungles replace. #815

Open
krainboltgreene opened this issue Aug 13, 2024 · 9 comments

Comments

@krainboltgreene
Copy link

krainboltgreene commented Aug 13, 2024

I did a search/replace in VSCode for "Core" to "Dashboard" across many files (200~) and VSCode hangs while letting Lexical format it. This also seems to result in future search/replace issues as a replace of Core.AccountAuth to Dashboard.AccountAuth turns Core.AccountAuth, :ensure_authenticated into Dashboard.AccountAuthure_authenticated. While the below screenshot shows them being saved each "save" takes ~3s and actually finishes (it's not locked up). That said the file is already saved, regardless of what the indicator says.

Screenshot 2024-08-13 at 10 18 30 AM

Metadata:

Version: 1.92.1 (Universal)
Commit: eaa41d57266683296de7d118f574d0c2652e1fc4
Date: 2024-08-07T20:16:39.455Z (5 days ago)
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Darwin arm64 22.6.0
Lexical Extension: lexical-lsp.lexical v0.0.18
Erlang/OTP 27 [erts-15.0] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]
Elixir 1.17.1 (compiled with Erlang/OTP 27)
@scohen
Copy link
Collaborator

scohen commented Aug 19, 2024

I've been able to replicate this, going to play around with this a bit and see if I can make this perform better.

@crbelaus
Copy link

crbelaus commented Sep 4, 2024

This happens to me frequently as well. I have the format on save setting enabled and Lexical seems to be formatting the file and rebuilding the application for each saved file.

I wonder if it would make sense to have some kind of "debounce" to delay the application rebuild for a few milliseconds after saving a file. This way it would be triggered only after saving all the files instead of once for every file.

@scohen
Copy link
Collaborator

scohen commented Sep 5, 2024

The build presently already has a debounce, but format doesn't.
Things get a little tricky with debounces, because format requests expect a response within some amount of time, and they operate on an unsaved document. Thus, if you miss that window, there's no way that I know of to actually format the document.

@scohen
Copy link
Collaborator

scohen commented Sep 5, 2024

@krainboltgreene @crbelaus can you check out the branch in #826, and see if that helps?

@krainboltgreene
Copy link
Author

Will do.

@krainboltgreene
Copy link
Author

Queuing this up for tonight, sorry was super busy yesterday.

@Moosieus
Copy link
Collaborator

I gave this a quick spot-check on main since #826 was merged, and it seems like this issue's resolved.

If someone may verify, I'll mark this issue as completed.

@scohen
Copy link
Collaborator

scohen commented Nov 20, 2024

@krainboltgreene Can you verify?

@krainboltgreene
Copy link
Author

krainboltgreene commented Nov 20, 2024

It's very simple to test, I will do so in 14h when I start work again. (In case I fall off the earth the test is this: (1) turn on format-on-save in vscode, (2) turn on auto-save on unfocus, (3) search-and-replace for something small fooooooooooooooooooo and replace it with something absurdly long fooooooooooooooooooo, this will cause a multiline format, and if this change works you won't lose any code)

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

No branches or pull requests

4 participants