diff --git a/src/langs/blueprint/blueprint.js b/src/langs/blueprint/blueprint.js index cd3ca5480..c5ff64990 100644 --- a/src/langs/blueprint/blueprint.js +++ b/src/langs/blueprint/blueprint.js @@ -56,10 +56,11 @@ export function setup({ document }) { }, }); - console.log(text_edits); - if (!text_edits) return text; + if (!text_edits || text_edits.length !== 1) return text; + const newText = text_edits[0].newText; + if (!newText) return text; - return applyTextEdits(text_edits, text); + return newText; }, }; } @@ -124,12 +125,12 @@ export function logBlueprintInfo(info) { } function createLSPClient({ code_view, file }) { - const bin = "/app/bin/blueprint-compiler"; + // const bin = "/app/bin/blueprint-compiler"; const uri = file.get_uri(); - // const bin = GLib.build_filenamev([ - // pkg.sourcedir, - // "blueprint-compiler/blueprint-compiler.py", - // ]); + const bin = GLib.build_filenamev([ + "/home/sonny/Projects/GNOME", + "blueprint-compiler/blueprint-compiler.py", + ]); const lspc = new LSPClient([bin, "lsp"], { rootUri: file.get_parent().get_uri(), diff --git a/test/lsp.test.js b/test/lsp.test.js deleted file mode 100644 index e97425f73..000000000 --- a/test/lsp.test.js +++ /dev/null @@ -1,157 +0,0 @@ -import "./init.js"; - -import tst, { assert } from "../troll/tst/tst.js"; - -import { applyTextEdits } from "../src/langs/blueprint/blueprint.js"; - -const test = tst("applyTextEdits"); - -const text = ` - using Gtk 4.0; - - Box subtitle { - orientation: vertical; - halign: center; - margin-bottom: 30; - Label { - justify: center; - cool: "lol"; - } - } -`.trim(); - -test("no edits", () => { - assert.equal(applyTextEdits([], text), text); -}); - -test("without position changes", () => { - assert.equal( - applyTextEdits( - [ - { - range: { - start: { - line: 3, - character: 9, - }, - end: { - line: 3, - character: 10, - }, - }, - newText: "'", - }, - { - range: { - start: { - line: 3, - character: 13, - }, - end: { - line: 3, - character: 14, - }, - }, - newText: "'", - }, - ], - ` -using Gtk 4.0; - -Label { - label: "lol"; -}`.trim(), - ), - ` -using Gtk 4.0; - -Label { - label: 'lol'; -}`.trim(), - ); -}); - -test.only("with position changes", () => { - // console.log( - // "\n", - // applyTextEdits( - // [ - // { - // range: { - // start: { - // line: 0, - // character: 14, - // }, - // end: { - // line: 0, - // character: 14, - // }, - // }, - // newText: "\n", - // }, - // { - // range: { - // start: { - // line: 3, - // character: 1, - // }, - // end: { - // line: 3, - // character: 1, - // }, - // }, - // newText: "\n", - // }, - // ], - // `using Gtk 4.0; - // Label { - // label: 'lol'; - // }`, - // ), - // ); - - assert.equal( - applyTextEdits( - [ - { - range: { - start: { - line: 0, - character: 14, - }, - end: { - line: 0, - character: 14, - }, - }, - newText: "\n", - }, - { - range: { - start: { - line: 3, - character: 1, - }, - end: { - line: 3, - character: 1, - }, - }, - newText: "\n", - }, - ], - `using Gtk 4.0; -Label { - label: 'lol'; -}`, - ), - `using Gtk 4.0; - -Label { - label: 'lol'; - -}`, // FIXME the newline should be at the end - ); -}); - -export default test;