Skip to content

Commit 029732d

Browse files
committed
Delete temporary files
1 parent 16f7194 commit 029732d

File tree

4 files changed

+29
-30
lines changed

4 files changed

+29
-30
lines changed

src/langs/blueprint/blueprint.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,12 @@ import LSPClient from "../../lsp/LSPClient.js";
66
import { once } from "../../../troll/src/util.js";
77

88
export function setup({ data_dir, document }) {
9-
const { code_view } = document;
10-
11-
// FIXME: Blueprint language server emits a KeyError for this
12-
// const { file } = document;
13-
// const uri = state_file.get_uri();
14-
const uri = "workbench://state.blp";
9+
const { file, code_view } = document;
1510

1611
const lspc = createLSPClient({
17-
data_dir,
18-
uri,
1912
code_view,
13+
uri: file.get_uri(),
14+
data_dir,
2015
});
2116

2217
lspc.start().catch(logError);
@@ -94,8 +89,11 @@ function createLSPClient({ code_view, data_dir, uri }) {
9489

9590
lspc.connect(
9691
"notification::textDocument/publishDiagnostics",
97-
(_self, { diagnostics }) => {
98-
code_view.handleDiagnostics(diagnostics);
92+
(_self, params) => {
93+
if (params.uri !== uri) {
94+
return;
95+
}
96+
code_view.handleDiagnostics(params.diagnostics);
9997
},
10098
);
10199

src/langs/javascript/javascript.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ import Gio from "gi://Gio";
33
import LSPClient from "../../lsp/LSPClient.js";
44

55
export function setup({ data_dir, document }) {
6-
const { file: state_file, code_view } = document;
6+
const { file, code_view } = document;
77

8-
const uri = state_file.get_uri();
98
const lspc = createLSPClient({
10-
uri,
119
code_view,
10+
uri: file.get_uri(),
1211
data_dir,
13-
state_file,
1412
});
1513

1614
lspc.start().catch(logError);
@@ -20,7 +18,7 @@ export function setup({ data_dir, document }) {
2018
});
2119
}
2220

23-
function createLSPClient({ uri, code_view, data_dir, state_file }) {
21+
function createLSPClient({ uri, code_view, data_dir }) {
2422
const lspc = new LSPClient(["rome", "lsp-proxy"], {
2523
rootUri: Gio.File.new_for_path(data_dir).get_uri(),
2624
uri,
@@ -72,11 +70,11 @@ function createLSPClient({ uri, code_view, data_dir, state_file }) {
7270
// https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_publishDiagnostics
7371
lspc.connect(
7472
"notification::textDocument/publishDiagnostics",
75-
(_self, { diagnostics, uri }) => {
76-
if (!state_file.equal(Gio.File.new_for_uri(uri))) {
73+
(_self, params) => {
74+
if (params.uri !== uri) {
7775
return;
7876
}
79-
code_view.handleDiagnostics(diagnostics);
77+
code_view.handleDiagnostics(params.diagnostics);
8078
},
8179
);
8280

src/langs/vala/vala.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ import GLib from "gi://GLib";
44
import LSPClient from "../../lsp/LSPClient.js";
55

66
export function setup({ data_dir, document }) {
7-
const { file: state_file, code_view } = document;
7+
const { file, code_view } = document;
88

99
const api_file = Gio.File.new_for_path(
1010
GLib.build_filenamev([pkg.pkgdatadir, "workbench-api.vala"]),
1111
);
1212

13-
const uri = state_file.get_uri();
14-
1513
api_file.copy(
1614
Gio.File.new_for_path(data_dir).get_child("workbench.vala"),
1715
Gio.FileCopyFlags.OVERWRITE,
@@ -21,9 +19,8 @@ export function setup({ data_dir, document }) {
2119

2220
const lspc = createLSPClient({
2321
code_view,
24-
uri,
22+
uri: file.get_uri(),
2523
data_dir,
26-
state_file,
2724
});
2825

2926
lspc.start().catch(logError);
@@ -33,7 +30,7 @@ export function setup({ data_dir, document }) {
3330
});
3431
}
3532

36-
function createLSPClient({ code_view, uri, data_dir, state_file }) {
33+
function createLSPClient({ code_view, uri, data_dir }) {
3734
const lspc = new LSPClient(
3835
[
3936
// "/usr/lib/sdk/vala/bin/vala-language-server",
@@ -58,11 +55,11 @@ function createLSPClient({ code_view, uri, data_dir, state_file }) {
5855

5956
lspc.connect(
6057
"notification::textDocument/publishDiagnostics",
61-
(_self, { diagnostics, uri }) => {
62-
if (!state_file.equal(Gio.File.new_for_uri(uri))) {
58+
(_self, params) => {
59+
if (params.uri !== uri) {
6360
return;
6461
}
65-
code_view.handleDiagnostics(diagnostics);
62+
code_view.handleDiagnostics(params.diagnostics);
6663
},
6764
);
6865

src/window.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,7 @@ export default function Window({ application }) {
258258
file_javascript,
259259
"replace_contents_async",
260260
"replace_contents_finish",
261-
new GLib.Bytes(
262-
langs.javascript.document.code_view.buffer.text || " ",
263-
),
261+
new GLib.Bytes(document_javascript.code_view.buffer.text || " "),
264262
null,
265263
false,
266264
Gio.FileCreateFlags.NONE,
@@ -272,6 +270,14 @@ export default function Window({ application }) {
272270
} catch (err) {
273271
previewer.update();
274272
throw err;
273+
} finally {
274+
promiseTask(
275+
file_javascript,
276+
"delete_async",
277+
"delete_finish",
278+
GLib.PRIORITY_DEFAULT,
279+
null,
280+
).catch(logError);
275281
}
276282
previewer.setSymbols(exports);
277283
} else if (language === "Vala") {

0 commit comments

Comments
 (0)