Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Commit 43409a9

Browse files
committed
Refactor: clean up documentText.
1 parent 08511f7 commit 43409a9

File tree

4 files changed

+8
-18
lines changed

4 files changed

+8
-18
lines changed

src/rescript-editor-support/MessageHandlers.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let handlers:
4242
let%try (uri, pos) = Protocol.rPositionParams(params);
4343
let maybeText =
4444
switch (Hashtbl.find_opt(state.documentText, uri)) {
45-
| Some((text, _version, _isClean)) => Some(text)
45+
| Some(text) => Some(text)
4646
| None => None
4747
};
4848
let%try (package, full) = State.getFullFromCmt(~state, ~uri);

src/rescript-editor-support/NotificationHandlers.re

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ module J = JsonShort;
55

66
let getTextDocument = doc => {
77
let%opt uri = Json.get("uri", doc) |?> Json.string;
8-
let%opt version = Json.get("version", doc) |?> Json.number;
98
let%opt text = Json.get("text", doc) |?> Json.string;
10-
Some((uri, version, text));
9+
Some((uri, text));
1110
};
1211

1312
let watchedFileContentsMap = Hashtbl.create(100);
@@ -22,15 +21,11 @@ let notificationHandlers:
2221
(
2322
"textDocument/didOpen",
2423
(state, params) => {
25-
let%try (uri, version, text) =
24+
let%try (uri, text) =
2625
Json.get("textDocument", params)
2726
|?> getTextDocument
2827
|> RResult.orError("Invalid params");
29-
Hashtbl.replace(
30-
state.documentText,
31-
uri,
32-
(text, int_of_float(version), true),
33-
);
28+
Hashtbl.replace(state.documentText, uri, text);
3429

3530
let%try path = Utils.parseUri(uri) |> RResult.orError("Invalid uri");
3631
if (FindFiles.isSourceFile(path)) {
@@ -76,14 +71,13 @@ let notificationHandlers:
7671
open InfixResult;
7772
let%try doc = params |> RJson.get("textDocument");
7873
let%try uri = RJson.get("uri", doc) |?> RJson.string;
79-
let%try version = RJson.get("version", doc) |?> RJson.number;
8074
let%try changes = RJson.get("contentChanges", params) |?> RJson.array;
8175
let%try text =
8276
List.nth(changes, List.length(changes) - 1)
8377
|> RJson.get("text")
8478
|?> RJson.string;
8579
/* Hmm how do I know if it's modified? */
86-
let state = State.updateContents(uri, text, version, state);
80+
let state = State.updateContents(uri, text, state);
8781
Ok(state);
8882
},
8983
),

src/rescript-editor-support/State.re

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,8 @@ let docsForCmt = (~moduleName, cmt, src, state) =>
4747
};
4848
};
4949

50-
let updateContents = (uri, text, version, state) => {
51-
Hashtbl.replace(
52-
state.documentText,
53-
uri,
54-
(text, int_of_float(version), false),
55-
);
50+
let updateContents = (uri, text, state) => {
51+
Hashtbl.replace(state.documentText, uri, text);
5652
state;
5753
};
5854

src/rescript-editor-support/TopTypes.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type package = {
1818

1919
type state = {
2020
rootUri: uri,
21-
documentText: Hashtbl.t(uri, (string, int, bool)),
21+
documentText: Hashtbl.t(uri, string),
2222
packagesByRoot: Hashtbl.t(string, package),
2323
rootForUri: Hashtbl.t(uri, string),
2424
cmtCache: Hashtbl.t(filePath, (float, SharedTypes.file)),

0 commit comments

Comments
 (0)