feat(format): add runtime semantic-equality safety gate
This commit is contained in:
@@ -124,6 +124,10 @@ func (s *server) handle(raw []byte) bool {
|
||||
s.reply(req.ID, []textEdit{})
|
||||
return false
|
||||
}
|
||||
if !format.SemanticallyEqual(text, formatted) {
|
||||
s.reply(req.ID, []textEdit{})
|
||||
return false
|
||||
}
|
||||
s.reply(req.ID, []textEdit{fullReplace(text, formatted)})
|
||||
case "textDocument/rangeFormatting":
|
||||
var p rangeFormattingParams
|
||||
@@ -224,6 +228,9 @@ func (s *server) rangeFormat(text string, r lspRange) []textEdit {
|
||||
if formatted == text {
|
||||
return nil
|
||||
}
|
||||
if !format.SemanticallyEqual(text, formatted) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Split both versions into lines, keeping the trailing newline attached to
|
||||
// each element so that joining them reconstructs the original string.
|
||||
|
||||
Reference in New Issue
Block a user