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

fix: return empty response to textDocument/formatting if no changes #3142

Merged

Conversation

danielleontiev
Copy link
Contributor

Do not send "edits" if the content remains unchanged after LSP formatting. Otherwise, Neovim reports an unsaved buffer even when no actual changes were made

Do not send "edits" if the content remains unchanged after LSP
formatting. Otherwise, Neovim reports an unsaved buffer even when no
actual changes were made
@danielleontiev danielleontiev force-pushed the text-document-format-no-changes branch from 7ea9e7c to aa273e3 Compare March 30, 2025 14:31
@danielleontiev danielleontiev changed the title feat: return empty response to textDocument/formatting if no changes fix: return empty response to textDocument/formatting if no changes Mar 30, 2025
@CppCXY CppCXY requested a review from Copilot March 31, 2025 06:59
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that no edits are sent when the LSP formatting results in no content changes, preventing Neovim from marking buffers as unsaved.

  • Updated changelog entry documenting the fix
  • Clarified behavior of textDocument/formatting
Files not reviewed (1)
  • script/core/formatting.lua: Language not supported

@sumneko
Copy link
Collaborator

sumneko commented Apr 5, 2025

Thank you!

@sumneko sumneko merged commit c3334eb into LuaLS:master Apr 5, 2025
11 checks passed
@danielleontiev danielleontiev deleted the text-document-format-no-changes branch April 5, 2025 08:51
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.

2 participants