Skip to content

Commit d09f3e4

Browse files
committed
Clean: word wrap.
1 parent 80fbd85 commit d09f3e4

File tree

5 files changed

+53
-32
lines changed

5 files changed

+53
-32
lines changed

client/src/CodeChatEditor.mts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ export const on_dom_content_loaded = (on_load_func: () => void) => {
222222
//
223223
// True if this is a CodeChat Editor document (not a source file).
224224
const is_doc_only = () => {
225-
// This might be called by the framework before a document is loaded.
226-
// So, make sure `current_metadata` exists first.
225+
// This might be called by the framework before a document is loaded. So,
226+
// make sure `current_metadata` exists first.
227227
return current_metadata?.["mode"] === "markdown";
228228
};
229229

@@ -372,8 +372,8 @@ const save_lp = (is_dirty: boolean) => {
372372
"CodeChat-body",
373373
) as HTMLDivElement;
374374
mathJaxUnTypeset(codechat_body);
375-
// To save a document only, simply get the HTML from the only Tiny MCE
376-
// div.
375+
// To save a document only, simply get the HTML from the only Tiny
376+
// MCE div.
377377
tinymce.activeEditor!.save();
378378
const html = tinymce.activeEditor!.getContent();
379379
(
@@ -556,8 +556,8 @@ const save_then_navigate = (codeChatEditorUrl: URL) => {
556556
});
557557
};
558558

559-
// This can be called by the framework. Therefore, make no assumptions
560-
// about variables being valid; it be called before a file is loaded, etc.
559+
// This can be called by the framework. Therefore, make no assumptions about
560+
// variables being valid; it be called before a file is loaded, etc.
561561
const scroll_to_line = (line: number) => {
562562
if (is_doc_only()) {
563563
// TODO.

client/src/CodeChatEditorFramework.mts

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ class WebSocketComm {
8989
// the `Update` may be applied immediately.
9090
is_loading = false;
9191

92-
// A promise to serialize calls to `set_content`.
92+
// A promise to serialize calls to and from the Client. This is important: a
93+
// `CurrentFile` requires the Client to save, then switch to a new web page.
94+
// If an `Update` comes in, it should be applied after the `CurrentFile` is
95+
// finished executing.
9396
promise = Promise.resolve();
9497

9598
constructor(ws_url: string) {
@@ -138,7 +141,8 @@ class WebSocketComm {
138141
case "Update":
139142
// Load this data in.
140143
const current_update = value as UpdateMessageContents;
141-
// The rest of this should run after all other messages have been processed.
144+
// The rest of this should run after all other messages have
145+
// been processed.
142146
this.promise = this.promise.finally(async () => {
143147
// Check or update the `current_filename`.
144148
if (this.current_filename === undefined) {
@@ -154,19 +158,24 @@ class WebSocketComm {
154158
const contents = current_update.contents;
155159
const cursor_position = current_update.cursor_position;
156160
if (contents !== undefined) {
157-
// I'd prefer to use a system-maintained value to determine the ready state of the iframe,
158-
// such as `readyState`. However, this value only applies to the initial load of the iframe;
159-
// it doesn't change when the iframe's `src` attribute is changed. So, we have to track
160-
// this manually instead.
161+
// I'd prefer to use a system-maintained value to
162+
// determine the ready state of the iframe, such as
163+
// `readyState`. However, this value only applies to
164+
// the initial load of the iframe; it doesn't change
165+
// when the iframe's `src` attribute is changed. So,
166+
// we have to track this manually instead.
161167
if (!this.is_loading) {
162-
// Wait until after the DOM is ready, since we rely on content set in `on_dom_content_loaded` in the Client.
168+
// Wait until after the DOM is ready, since we
169+
// rely on content set in
170+
// `on_dom_content_loaded` in the Client.
163171
await set_content(
164172
contents,
165173
current_update.cursor_position,
166174
);
167175
} else {
168-
// If the page is still loading, wait until the load
169-
// completes before updating the editable contents.
176+
// If the page is still loading, wait until the
177+
// load completes before updating the editable
178+
// contents.
170179
//
171180
// Construct the promise to use; this causes the
172181
// `onload` callback to be set immediately.
@@ -184,8 +193,8 @@ class WebSocketComm {
184193
}
185194
} else if (cursor_position !== undefined) {
186195
// We might receive a message while the Client is
187-
// reloading; during this period, `scroll_to_line` isn't
188-
// defined.
196+
// reloading; during this period, `scroll_to_line`
197+
// isn't defined.
189198
root_iframe!.contentWindow?.CodeChatEditor?.scroll_to_line?.(
190199
cursor_position,
191200
);
@@ -206,15 +215,16 @@ class WebSocketComm {
206215
? "?test"
207216
: "&test"
208217
: "";
209-
// Execute this after all other messages have been processed.
218+
// Execute this after all other messages have been
219+
// processed.
210220
this.promise = this.promise.finally(async () => {
211-
// If the page is still loading, then don't save. Otherwise,
212-
// save the editor contents if necessary.
221+
// If the page is still loading, then don't save.
222+
// Otherwise, save the editor contents if necessary.
213223
const cce = get_client();
214224
await cce?.on_save(true);
215-
// Now, it's safe to load a new file.
216-
// Tell the client to allow this navigation -- the
217-
// document it contains has already been saved.
225+
// Now, it's safe to load a new file. Tell the client to
226+
// allow this navigation -- the document it contains has
227+
// already been saved.
218228
if (cce !== undefined) {
219229
cce.allow_navigation = true;
220230
}
@@ -313,7 +323,8 @@ class WebSocketComm {
313323
current_file = (url: URL) => {
314324
this.promise = this.promise.finally(() => {
315325
if (url.host === window.location.host) {
316-
// If this points to the Server, then tell the IDE to load a new file.
326+
// If this points to the Server, then tell the IDE to load a new
327+
// file.
317328
this.send_message(
318329
{ CurrentFile: [url.toString(), null] },
319330
() => {

client/src/assert.mts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// `assert.mts`
22
// ============
3-
// Provide a simple `assert` function to check conditions at runtime. Using things like [assert](https://nodejs.org/api/assert.html) causes problems -- somehow, this indicates that the code is running in a development environment (see [this](https://github.com/micromark/micromark/issues/87#issuecomment-908924233)).
4-
//
3+
////
4+
// Provide a simple `assert` function to check conditions at runtime. Using
5+
// things like [assert](https://nodejs.org/api/assert.html) causes problems --
6+
// somehow, this indicates that the code is running in a development environment
7+
// (see
8+
// [this](https://github.com/micromark/micromark/issues/87#issuecomment-908924233)).
59
// Taken from the TypeScript
610
// [docs](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#assertion-functions).
711
export function assert(condition: any, msg?: string): asserts condition {

docs/changelog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ Changelog
2222
[Github master](https://github.com/bjones1/CodeChat_Editor)
2323
-----------------------------------------------------------
2424

25-
* Fix and improve test framework.
25+
* Correct ordering of messages sent to and from the Framework to the Client.
26+
* Fix and improve test framework and error reporting.
2627
* Improve MathJax bundling.
28+
* Update PDF viewer.
2729

2830
Version 0.1.29 -- 2025-23-Aug
2931
-----------------------------

server/src/webserver.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ macro_rules! queue_send {
341341

342342
/// Globals
343343
/// -------
344-
// The timeout for a reply from a websocket, in ms. Use a short timeout to speed up
345-
// unit tests.
344+
// The timeout for a reply from a websocket, in ms. Use a short timeout to speed
345+
// up unit tests.
346346
const REPLY_TIMEOUT_MS: Duration = if cfg!(test) {
347347
Duration::from_millis(500)
348348
} else {
@@ -353,7 +353,8 @@ const REPLY_TIMEOUT_MS: Duration = if cfg!(test) {
353353
/// this server.
354354
const WEBSOCKET_PING_DELAY: Duration = Duration::from_secs(2);
355355

356-
/// A message ID which won't be used by anything but a `Result` produced by an error not produced in response to a message.
356+
/// A message ID which won't be used by anything but a `Result` produced by an
357+
/// error not produced in response to a message.
357358
pub const RESERVED_MESSAGE_ID: f64 = if cfg!(test) {
358359
// A simpler value when testing.
359360
0.0
@@ -392,7 +393,8 @@ const MATHJAX_TAGS: &str = concatdoc!(
392393
r#"
393394
<script>
394395
MathJax = {"#,
395-
// See the [docs](https://docs.mathjax.org/en/latest/options/output/chtml.html#option-descriptions).
396+
// See the
397+
// [docs](https://docs.mathjax.org/en/latest/options/output/chtml.html#option-descriptions).
396398
r#"
397399
chtml: {
398400
fontURL: "/static/mathjax-newcm-font/chtml/woff2",
@@ -402,7 +404,9 @@ const MATHJAX_TAGS: &str = concatdoc!(
402404
},
403405
};
404406
</script>"#,
405-
// Per the [MathJax docs](https://docs.mathjax.org/en/latest/web/components/combined.html#tex-chtml), enable tex input and HTML output.
407+
// Per the [MathJax
408+
// docs](https://docs.mathjax.org/en/latest/web/components/combined.html#tex-chtml),
409+
// enable tex input and HTML output.
406410
r#"
407411
<script defer src="/static/mathjax/tex-chtml.js"></script>"#
408412
);

0 commit comments

Comments
 (0)