mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Use a single text edit for lsp formatter
This commit is contained in:
parent
825f6e3b15
commit
c994460b1e
1 changed files with 10 additions and 13 deletions
|
@ -22,7 +22,6 @@ import json
|
|||
import sys
|
||||
import traceback
|
||||
import typing as T
|
||||
from difflib import SequenceMatcher
|
||||
|
||||
from . import decompiler, parser, tokenizer, utils, xml_reader
|
||||
from .ast_utils import AstNode
|
||||
|
@ -304,19 +303,17 @@ class LanguageServer:
|
|||
params["options"]["insertSpaces"],
|
||||
)
|
||||
|
||||
lst = []
|
||||
for tag, i1, i2, j1, j2 in SequenceMatcher(
|
||||
None, open_file.text, formatted_blp
|
||||
).get_opcodes():
|
||||
if tag in ("replace", "insert", "delete"):
|
||||
lst.append(
|
||||
text_edits = []
|
||||
|
||||
if formatted_blp != open_file.text:
|
||||
text_edits.append(
|
||||
TextEdit(
|
||||
Range(i1, i2, open_file.text),
|
||||
"" if tag == "delete" else formatted_blp[j1:j2],
|
||||
Range(0, len(open_file.text), open_file.text),
|
||||
formatted_blp,
|
||||
).to_json()
|
||||
)
|
||||
|
||||
self._send_response(id, lst)
|
||||
self._send_response(id, text_edits)
|
||||
|
||||
@command("textDocument/x-blueprint-compile")
|
||||
def compile(self, id, params):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue