Skip to content

Commit 7fadf00

Browse files
committed
Clean: wrap files.
1 parent a677ef4 commit 7fadf00

File tree

12 files changed

+271
-214
lines changed

12 files changed

+271
-214
lines changed

client/src/CodeChatEditorFramework.mts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ class WebSocketComm {
8181
// IDE and passed back to it, but not otherwise used by the Framework.
8282
current_filename: string | undefined = undefined;
8383

84-
// The version number of the current file. This default value will be overwritten when
85-
// the first `Update` is sent.
84+
// The version number of the current file. This default value will be
85+
// overwritten when the first `Update` is sent.
8686
version = 0.0;
8787

8888
// True when the iframe is loading, so that an `Update` should be postponed
@@ -164,7 +164,9 @@ class WebSocketComm {
164164
const contents = current_update.contents;
165165
const cursor_position = current_update.cursor_position;
166166
if (contents !== undefined) {
167-
// Check and update the version. If this is a diff, ensure the diff was made against the version of the file we have.
167+
// Check and update the version. If this is a diff,
168+
// ensure the diff was made against the version of
169+
// the file we have.
168170
if ("Diff" in contents.source) {
169171
if (
170172
contents.source.Diff.version !==

client/src/CodeMirror-integration.mts

Lines changed: 58 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ declare global {
119119
// When this is included in a transaction, don't update from/to of doc blocks.
120120
const docBlockFreezeAnnotation = Annotation.define<boolean>();
121121

122-
// When this is included in a transaction, don't send autosave scroll/cursor location updates.
122+
// When this is included in a transaction, don't send autosave scroll/cursor
123+
// location updates.
123124
const noAutosaveAnnotation = Annotation.define<boolean>();
124125

125126
// Doc blocks in CodeMirror
@@ -276,7 +277,8 @@ export const docBlockField = StateField.define<DecorationSet>({
276277
prev.spec.widget.contents,
277278
effect.value.contents,
278279
),
279-
// Assume this isn't a user change unless it's specified.
280+
// Assume this isn't a user change unless it's
281+
// specified.
280282
effect.value.is_user_change ?? false,
281283
),
282284
...decorationOptions,
@@ -373,7 +375,8 @@ type updateDocBlockType = {
373375
indent?: string;
374376
delimiter?: string;
375377
contents: string | StringDiff[];
376-
// True if this update comes from a user change, as opposed to an update received from the IDE.
378+
// True if this update comes from a user change, as opposed to an update
379+
// received from the IDE.
377380
is_user_change?: boolean;
378381
};
379382

@@ -447,7 +450,8 @@ class DocBlockWidget extends WidgetType {
447450
`<div class="CodeChat-doc-contents" spellcheck contenteditable>` +
448451
this.contents +
449452
"</div>";
450-
// TODO: this is an async call. However, CodeMirror doesn't provide async support.
453+
// TODO: this is an async call. However, CodeMirror doesn't provide
454+
// async support.
451455
mathJaxTypeset(wrap);
452456
return wrap;
453457
}
@@ -457,7 +461,8 @@ class DocBlockWidget extends WidgetType {
457461
// "Update a DOM element created by a widget of the same type (but
458462
// different, non-eq content) to reflect this widget."
459463
updateDOM(dom: HTMLElement, _view: EditorView): boolean {
460-
// If this change was produced by a user edit, then the DOM was already updated. Stop here.
464+
// If this change was produced by a user edit, then the DOM was already
465+
// updated. Stop here.
461466
if (this.is_user_change) {
462467
console.log("user change -- skipping DOM update.");
463468
return true;
@@ -469,7 +474,8 @@ class DocBlockWidget extends WidgetType {
469474
const [contents_div, is_tinymce] = get_contents(dom);
470475
window.MathJax.typesetClear(contents_div);
471476
if (is_tinymce) {
472-
// Save the cursor location before the update, then restore it afterwards, if TinyMCE has focus.
477+
// Save the cursor location before the update, then restore it
478+
// afterwards, if TinyMCE has focus.
473479
const sel = tinymce_singleton!.hasFocus()
474480
? saveSelection()
475481
: undefined;
@@ -482,7 +488,8 @@ class DocBlockWidget extends WidgetType {
482488
}
483489
mathJaxTypeset(contents_div);
484490

485-
// Indicate the update was successful. TODO: but, contents are still pending...
491+
// Indicate the update was successful. TODO: but, contents are still
492+
// pending...
486493
return true;
487494
}
488495

@@ -513,44 +520,36 @@ class DocBlockWidget extends WidgetType {
513520
}
514521

515522
const saveSelection = () => {
516-
// Changing the text inside TinyMCE causes it to loose a selection
517-
// tied to a specific node. So, instead store the
518-
// selection as an array of indices in the childNodes
519-
// array of each element: for example, a given selection
520-
// is element 10 of the root TinyMCE div's children
521-
// (selecting an ol tag), element 5 of the ol's children
522-
// (selecting the last li tag), element 0 of the li's
523-
// children (a text node where the actual click landed;
524-
// the offset in this node is placed in
525-
// `selection_offset`.)
523+
// Changing the text inside TinyMCE causes it to loose a selection tied to a
524+
// specific node. So, instead store the selection as an array of indices in
525+
// the childNodes array of each element: for example, a given selection is
526+
// element 10 of the root TinyMCE div's children (selecting an ol tag),
527+
// element 5 of the ol's children (selecting the last li tag), element 0 of
528+
// the li's children (a text node where the actual click landed; the offset
529+
// in this node is placed in `selection_offset`.)
526530
const sel = window.getSelection();
527531
let selection_path = [];
528532
const selection_offset = sel?.anchorOffset;
529533
if (sel?.anchorNode) {
530-
// Find a path from the selection back to the
531-
// containing div.
534+
// Find a path from the selection back to the containing div.
532535
for (
533536
let current_node = sel.anchorNode, is_first = true;
534-
// Continue until we find the div which contains
535-
// the doc block contents: either it's not an
536-
// element (such as a div), ...
537+
// Continue until we find the div which contains the doc block
538+
// contents: either it's not an element (such as a div), ...
537539
current_node.nodeType !== Node.ELEMENT_NODE ||
538540
// or it's not the doc block contents div.
539541
!(current_node as Element).classList.contains(
540542
"CodeChat-doc-contents",
541543
);
542544
current_node = current_node.parentNode!, is_first = false
543545
) {
544-
// Store the index of this node in its' parent
545-
// list of child nodes/children. Use
546-
// `childNodes` on the first iteration, since
547-
// the selection is often in a text node, which
548-
// isn't in the `parents` list. However, using
549-
// `childNodes` all the time causes trouble when
550-
// reversing the selection -- sometimes, the
551-
// `childNodes` change based on whether text
552-
// nodes (such as a newline) are included are
553-
// not after tinyMCE parses the content.
546+
// Store the index of this node in its' parent list of child
547+
// nodes/children. Use `childNodes` on the first iteration, since
548+
// the selection is often in a text node, which isn't in the
549+
// `parents` list. However, using `childNodes` all the time causes
550+
// trouble when reversing the selection -- sometimes, the
551+
// `childNodes` change based on whether text nodes (such as a
552+
// newline) are included are not after tinyMCE parses the content.
554553
let p = current_node.parentNode!;
555554
selection_path.unshift(
556555
Array.prototype.indexOf.call(
@@ -563,28 +562,28 @@ const saveSelection = () => {
563562
return { selection_path, selection_offset };
564563
};
565564

566-
// Restore the selection produced by `saveSelection` to the active TinyMCE instance.
565+
// Restore the selection produced by `saveSelection` to the active TinyMCE
566+
// instance.
567567
const restoreSelection = ({
568568
selection_path,
569569
selection_offset,
570570
}: {
571571
selection_path: number[];
572572
selection_offset?: number;
573573
}) => {
574-
// Copy the selection over to TinyMCE by indexing the
575-
// selection path to find the selected node.
574+
// Copy the selection over to TinyMCE by indexing the selection path to find
575+
// the selected node.
576576
if (selection_path.length && typeof selection_offset === "number") {
577577
let selection_node = tinymce_singleton!.getContentAreaContainer();
578578
for (
579579
;
580580
selection_path.length &&
581-
// If something goes wrong, bail out instead of producing exceptions.
581+
// If something goes wrong, bail out instead of producing
582+
// exceptions.
582583
selection_node !== undefined;
583584
selection_node =
584-
// As before, use the more-consistent
585-
// `children` except for the last element,
586-
// where we might be selecting a `text`
587-
// node.
585+
// As before, use the more-consistent `children` except for the
586+
// last element, where we might be selecting a `text` node.
588587
(
589588
selection_path.length > 1
590589
? selection_node.children
@@ -662,8 +661,8 @@ const element_is_in_doc_block = (
662661
// untypeset, then the dirty ignored.
663662
// 3. When MathJax typesets math on a TinyMCE focus out event, the dirty flag
664663
// gets set. This should be ignored. However, typesetting is an async
665-
// operation, so we assume it's OK to await the typeset completion.
666-
// This will lead to nasty bugs at some point.
664+
// operation, so we assume it's OK to await the typeset completion. This will
665+
// lead to nasty bugs at some point.
667666
// 4. When an HTML doc block is assigned to the TinyMCE instance for editing,
668667
// the dirty flag is set. This must be ignored.
669668
const on_dirty = (
@@ -684,8 +683,8 @@ const on_dirty = (
684683
".CodeChat-doc",
685684
)! as HTMLDivElement;
686685

687-
// We can only get the position (the `from` value) for the doc block. Use
688-
// this to find the `to` value for the doc block.
686+
// We can only get the position (the `from` value) for the doc block.
687+
// Use this to find the `to` value for the doc block.
689688
let from;
690689
try {
691690
from = current_view.posAtDOM(target);
@@ -698,7 +697,8 @@ const on_dirty = (
698697
const indent = indent_div.innerHTML;
699698
const delimiter = indent_div.getAttribute("data-delimiter")!;
700699
const [contents_div, is_tinymce] = get_contents(target);
701-
// I'd like to extract this string, then untypeset only that string, not the actual div. But I don't know how.
700+
// I'd like to extract this string, then untypeset only that string, not
701+
// the actual div. But I don't know how.
702702
mathJaxUnTypeset(contents_div);
703703
const contents = is_tinymce
704704
? tinymce_singleton!.save()
@@ -828,7 +828,8 @@ export const DocBlockPlugin = ViewPlugin.fromClass(
828828
// cursor position (the selection) to be set in the
829829
// contenteditable div. Then, save that location.
830830
setTimeout(async () => {
831-
// Untypeset math in the old doc block and the current doc block before moving its contents around.
831+
// Untypeset math in the old doc block and the current
832+
// doc block before moving its contents around.
832833
const tinymce_div =
833834
document.getElementById("TinyMCE-inst")!;
834835
mathJaxUnTypeset(tinymce_div);
@@ -854,7 +855,8 @@ export const DocBlockPlugin = ViewPlugin.fromClass(
854855
old_contents_div,
855856
null,
856857
);
857-
// The previous content edited by TinyMCE is now a div. Retypeset this after the transition.
858+
// The previous content edited by TinyMCE is now a div.
859+
// Retypeset this after the transition.
858860
await mathJaxTypeset(old_contents_div);
859861
// Move TinyMCE to the new location, then remove the old
860862
// div it will replace.
@@ -1065,9 +1067,11 @@ export const CodeMirror_load = async (
10651067
// [docs](https://codemirror.net/examples/tab/). TODO:
10661068
// document a way to escape the tab key per the same docs.
10671069
keymap.of([indentWithTab]),
1068-
// Change the font size. See [this post](https://discuss.codemirror.net/t/changing-the-font-size-of-cm6/2935/6).
1070+
// Change the font size. See
1071+
// [this post](https://discuss.codemirror.net/t/changing-the-font-size-of-cm6/2935/6).
10691072
[
1070-
// TODO: get these values from the IDE, so we match its size.
1073+
// TODO: get these values from the IDE, so we match its
1074+
// size.
10711075
EditorView.theme({
10721076
"&": {
10731077
fontSize: "14px",
@@ -1092,7 +1096,8 @@ export const CodeMirror_load = async (
10921096
await init({
10931097
selector: "#TinyMCE-inst",
10941098
setup: (editor: Editor) => {
1095-
// See the [docs](https://www.tiny.cloud/docs/tinymce/latest/events/#editor-core-events).
1099+
// See the
1100+
// [docs](https://www.tiny.cloud/docs/tinymce/latest/events/#editor-core-events).
10961101
editor.on("Dirty", (event: any) => {
10971102
// Get the div TinyMCE stores edits in. TODO: find
10981103
// documentation for `event.target.bodyElement`.
@@ -1158,7 +1163,9 @@ export const scroll_to_line = (cursor_line?: number, scroll_line?: number) => {
11581163
return;
11591164
}
11601165

1161-
// Create a transaction to set the cursor and scroll position. Avoid an autosave that sends updated cursor/scroll positions produced by this transaction.
1166+
// Create a transaction to set the cursor and scroll position. Avoid an
1167+
// autosave that sends updated cursor/scroll positions produced by this
1168+
// transaction.
11621169
const dispatch_data: TransactionSpec = {
11631170
annotations: noAutosaveAnnotation.of(true),
11641171
};

client/src/debug_enabled.mts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
// [http://www.gnu.org/licenses](http://www.gnu.org/licenses).
1616
//
1717
// `debug_enable.mts` -- Configure debug features
18-
// ==============================================
18+
// =============================================================================
1919
// True to enable additional debug logging.
2020
export const DEBUG_ENABLED = false;
2121

22-
// The max length of a message to show in the console when debug logging is enabled.
22+
// The max length of a message to show in the console when debug logging is
23+
// enabled.
2324
export const MAX_MESSAGE_LENGTH = 20000;

client/src/show_toast.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// [http://www.gnu.org/licenses](http://www.gnu.org/licenses).
1616
//
1717
// `show_toast.mts` -- Show a toast message
18-
// ========================================
18+
// =============================================================================
1919
import Toastify from "toastify-js";
2020
import "toastify-js/src/toastify.css";
2121

extensions/VSCode/src/extension.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,10 @@ export const activate = (context: vscode.ExtensionContext) => {
335335
}
336336
if (current_update.contents !== undefined) {
337337
const source = current_update.contents.source;
338-
// This will
339-
// produce a change event, which we'll ignore. The change may also produce a selection change, which should also be ignored.
338+
// This will produce a change event, which we'll
339+
// ignore. The change may also produce a
340+
// selection change, which should also be
341+
// ignored.
340342
ignore_text_document_change = true;
341343
ignore_selection_change = true;
342344
// Use a workspace edit, since calls to
@@ -359,10 +361,12 @@ export const activate = (context: vscode.ExtensionContext) => {
359361
);
360362
} else {
361363
assert("Diff" in source);
362-
// If this diff was not made against the text we currently have, reject it.
364+
// If this diff was not made against the
365+
// text we currently have, reject it.
363366
if (source.Diff.version !== version) {
364367
await sendResult(id, "OutOfSync");
365-
// Send an `Update` with the full text to re-sync the Client.
368+
// Send an `Update` with the full text to
369+
// re-sync the Client.
366370
send_update(true);
367371
break;
368372
}
@@ -395,7 +399,8 @@ export const activate = (context: vscode.ExtensionContext) => {
395399
ignore_text_document_change = false;
396400
ignore_selection_change = false;
397401
});
398-
// Now that we've updated our text, update the associated version as well.
402+
// Now that we've updated our text, update the
403+
// associated version as well.
399404
version = current_update.contents.version;
400405
}
401406

@@ -720,7 +725,8 @@ const can_render = () => {
720725
(vscode.window.activeTextEditor !== undefined ||
721726
current_editor !== undefined) &&
722727
codeChatEditorServer !== undefined &&
723-
// TODO: I don't think these matter -- the Server is in charge of sending output to the Client.
728+
// TODO: I don't think these matter -- the Server is in charge of
729+
// sending output to the Client.
724730
(codechat_client_location === CodeChatEditorClientLocation.browser ||
725731
webview_panel !== undefined)
726732
);

server/src/ide.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
// the CodeChat Editor. If not, see
1515
// [http://www.gnu.org/licenses](http://www.gnu.org/licenses).
1616
/// `ide.rs` -- Provide interfaces with common IDEs
17-
/// ===============================================
17+
/// ============================================================================
1818
pub mod filewatcher;
1919
pub mod vscode;
2020

2121
// Imports
22-
// -------
22+
// -----------------------------------------------------------------------------
2323
//
2424
// ### Standard library
2525
use std::{
@@ -57,7 +57,7 @@ use crate::{
5757
};
5858

5959
// Code
60-
// ----
60+
// -----------------------------------------------------------------------------
6161
//
6262
// Using this macro is critical -- otherwise, the Actix system doesn't get
6363
// correctly initialized, which makes calls to `actix_rt::spawn` fail. In

0 commit comments

Comments
 (0)