Skip to content

Commit ab8d838

Browse files
committed
Clean: prettier.
1 parent 238e88b commit ab8d838

File tree

10 files changed

+146
-143
lines changed

10 files changed

+146
-143
lines changed

client/src/CodeChatEditor-test.mts

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,19 @@
2626
// I can't get Mocha to work with ESBuild, so I import it using a script tag.
2727
import { assert } from "chai";
2828
import { EditorView } from "@codemirror/view";
29-
import { ChangeSpec, EditorState, EditorSelection, MapMode } from "@codemirror/state";
29+
import {
30+
ChangeSpec,
31+
EditorState,
32+
EditorSelection,
33+
MapMode,
34+
} from "@codemirror/state";
3035
import { exportedForTesting, page_init } from "./CodeChatEditor.mjs";
3136
import { CodeMirror, CodeMirrorDocBlockJson } from "./shared_types.mjs";
32-
import { docBlockField, DocBlockPlugin, CodeMirror_JSON_fields } from "./CodeMirror-integration.mjs";
37+
import {
38+
docBlockField,
39+
DocBlockPlugin,
40+
CodeMirror_JSON_fields,
41+
} from "./CodeMirror-integration.mjs";
3342

3443
// Re-export everything that [CodeChatEditor.mts](CodeChatEditor.mts) exports.
3544
// Otherwise, including [CodeChatEditor.mts](CodeChatEditor.mts) elsewhere would
@@ -117,17 +126,21 @@ window.CodeChatEditor_test = () => {
117126
) as HTMLDivElement;
118127
const testing_div = document.createElement("div");
119128
testing_div.id = "testing-div";
120-
codechat_body.insertBefore(testing_div, codechat_body.firstChild);
129+
codechat_body.insertBefore(
130+
testing_div,
131+
codechat_body.firstChild,
132+
);
121133

122134
// Test insert at beginning of doc block.
123-
const after_state = run_CodeMirror_test("a\nbcd", [[1, 2, "", "#", "test"]], { from: 1, insert: "\n" });
135+
const after_state = run_CodeMirror_test(
136+
"a\nbcd",
137+
[[1, 2, "", "#", "test"]],
138+
{ from: 1, insert: "\n" },
139+
);
124140
console.log(after_state);
125141
assert.deepEqual(after_state, {
126142
doc: "a\n\nbcd",
127-
doc_blocks:
128-
[
129-
[1, 3, "", "#", "test"]
130-
]
143+
doc_blocks: [[1, 3, "", "#", "test"]],
131144
});
132145
});
133146
});
@@ -138,7 +151,11 @@ window.CodeChatEditor_test = () => {
138151
mocha.run();
139152
};
140153

141-
const run_CodeMirror_test = (doc: string, doc_blocks: [CodeMirrorDocBlockJson], changes: ChangeSpec): CodeMirror => {
154+
const run_CodeMirror_test = (
155+
doc: string,
156+
doc_blocks: [CodeMirrorDocBlockJson],
157+
changes: ChangeSpec,
158+
): CodeMirror => {
142159
// Create the CodeChat Editor for testing.
143160
const editor_state_json = {
144161
doc,
@@ -148,9 +165,7 @@ const run_CodeMirror_test = (doc: string, doc_blocks: [CodeMirrorDocBlockJson],
148165
const state = EditorState.fromJSON(
149166
editor_state_json,
150167
{
151-
extensions: [
152-
DocBlockPlugin,
153-
],
168+
extensions: [DocBlockPlugin],
154169
},
155170
CodeMirror_JSON_fields,
156171
);
@@ -161,9 +176,9 @@ const run_CodeMirror_test = (doc: string, doc_blocks: [CodeMirrorDocBlockJson],
161176

162177
// Run a transaction, then extract at the results.
163178
view.dispatch({ changes });
164-
console.log(view.state.field(docBlockField))
179+
console.log(view.state.field(docBlockField));
165180
console.log(MapMode.TrackBefore);
166181
const after_state = view.state.toJSON(CodeMirror_JSON_fields);
167182
delete after_state.selection;
168183
return after_state;
169-
}
184+
};

client/src/CodeChatEditor.mts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,13 @@ const save_lp = () => {
316316
// div.
317317
tinymce.activeEditor!.save();
318318
const html = tinymce.activeEditor!.getContent();
319-
(code_mirror_diffable as {
320-
Plain: CodeMirror;
321-
}).Plain = {
319+
(
320+
code_mirror_diffable as {
321+
Plain: CodeMirror;
322+
}
323+
).Plain = {
322324
doc: turndownService.turndown(html),
323-
doc_blocks: []
325+
doc_blocks: [],
324326
};
325327
// Retypeset all math after saving the document.
326328
mathJaxTypeset(codechat_body);
@@ -362,9 +364,7 @@ const on_save = async (only_if_dirty: boolean = false) => {
362364
const webSocketComm = parent.window.CodeChatEditorFramework.webSocketComm;
363365
console.log("Sent Update - saving document.");
364366
await new Promise(async (resolve) => {
365-
webSocketComm.send_message({ Update: save_lp() }, () =>
366-
resolve(0),
367-
);
367+
webSocketComm.send_message({ Update: save_lp() }, () => resolve(0));
368368
});
369369
is_dirty = false;
370370
};

client/src/CodeMirror-integration.mts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ export const docBlockField = StateField.define<DecorationSet>({
151151
// in the document after this transaction completes.
152152
doc_blocks = doc_blocks.map(tr.changes);
153153
}
154+
// See [is](https://codemirror.net/docs/ref/#state.StateEffect.is). Add
155+
// a doc block, as requested by this effect.
154156
for (let effect of tr.effects)
155-
// See [is](https://codemirror.net/docs/ref/#state.StateEffect.is). Add
156-
// a doc block, as requested by this effect.
157157
if (effect.is(addDocBlock)) {
158158
// Perform an
159159
// [update](https://codemirror.net/docs/ref/#state.RangeSet.update)
@@ -972,24 +972,24 @@ export const CodeMirror_load = async (
972972
// This contains a diff, instead of plain text. Apply the text diff.
973973
//
974974
// First, apply just the text edits. Use an annotation so that the doc blocks aren't changed; without this, the diff won't work (since from/to values of doc blocks are changed by unfrozen text edits).
975-
current_view.dispatch(
976-
{
977-
changes: source.Diff.doc,
978-
annotations: docBlockFreezeAnnotation.of(true)
979-
},
980-
);
975+
current_view.dispatch({
976+
changes: source.Diff.doc,
977+
annotations: docBlockFreezeAnnotation.of(true),
978+
});
981979
// Now, apply the diff in a separate transaction. Applying them in the same transaction causes the text edits to modify from/to values in the doc block effects, even when changes to the doc block state is frozen.
982980
const stateEffects: StateEffect<any>[] = [];
983981
for (const transaction of source.Diff.doc_blocks) {
984982
if ("Add" in transaction) {
985983
const add = transaction.Add;
986-
stateEffects.push(addDocBlock.of({
987-
from: add[0],
988-
to: add[1],
989-
indent: add[2],
990-
delimiter: add[3],
991-
content: add[4],
992-
}));
984+
stateEffects.push(
985+
addDocBlock.of({
986+
from: add[0],
987+
to: add[1],
988+
indent: add[2],
989+
delimiter: add[3],
990+
content: add[4],
991+
}),
992+
);
993993
} else if ("Update" in transaction) {
994994
stateEffects.push(updateDocBlock.of(transaction.Update));
995995
} else if ("Delete" in transaction) {
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
// See http://go.microsoft.com/fwlink/?LinkId=827846
3-
// for the documentation about the extensions.json format
4-
"recommendations": [
5-
"dbaeumer.vscode-eslint"
6-
]
7-
}
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": ["dbaeumer.vscode-eslint"]
5+
}

extensions/VSCode/.vscode/launch.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
// Hover to view descriptions of existing attributes.
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
{
6-
"version": "0.2.0",
6+
"version": "0.2.0",
77
"configurations": [
88
{
99
"name": "Extension",
1010
"type": "extensionHost",
1111
"request": "launch",
1212
"runtimeExecutable": "${execPath}",
13-
"args": [
14-
"--extensionDevelopmentPath=${workspaceFolder}"
15-
]
13+
"args": ["--extensionDevelopmentPath=${workspaceFolder}"]
1614
},
1715
{
1816
"name": "Extension Tests",
@@ -25,4 +23,4 @@
2523
]
2624
}
2725
]
28-
}
26+
}

extensions/VSCode/.vscode/settings.json

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
"python.linting.pylintEnabled": false,
44
"python.linting.flake8Enabled": true,
55
"python.linting.enabled": true,
6-
"spellright.language": [
7-
"en"
8-
],
9-
"spellright.documentTypes": [
10-
"markdown",
11-
"latex",
12-
"plaintext",
13-
"python"
14-
]
15-
}
6+
"spellright.language": ["en"],
7+
"spellright.documentTypes": ["markdown", "latex", "plaintext", "python"]
8+
}
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
{
2-
// See https://go.microsoft.com/fwlink/?LinkId=733558
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
33
// for the documentation about the tasks.json format
44
"version": "2.0.0",
55
"tasks": [
66
{
77
"type": "typescript",
88
"tsconfig": "tsconfig.json",
9-
"problemMatcher": [
10-
"$tsc"
11-
],
9+
"problemMatcher": ["$tsc"],
1210
"group": {
1311
"kind": "build",
1412
"isDefault": true
1513
}
1614
}
1715
]
18-
}
16+
}

extensions/VSCode/jsconfig.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@
2222
"target": "es6",
2323
// Typecheck `.js` files.
2424
"checkJs": true,
25-
"lib": [
26-
"es6"
27-
]
25+
"lib": ["es6"]
2826
},
29-
"exclude": [
30-
"node_modules"
31-
]
32-
}
27+
"exclude": ["node_modules"]
28+
}

0 commit comments

Comments
 (0)