Skip to content

Commit bafa956

Browse files
committed
Fix: starting with CodeMirror/view 6.39, remove old patch.
1 parent 4d0b4b0 commit bafa956

File tree

5 files changed

+79
-64
lines changed

5 files changed

+79
-64
lines changed

builder/src/main.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,6 @@ fn patch_file(patch: &str, before_patch: &str, file_path: &str) -> io::Result<()
311311
}
312312
/// After updating files in the client's Node files, perform some fix-ups.
313313
fn patch_client_libs() -> io::Result<()> {
314-
// Apply a the fixes described in [issue
315-
// 27](https://github.com/bjones1/CodeChat_Editor/issues/27).
316-
patch_file(
317-
"
318-
selectionNotFocus = this.view.state.facet(editable) ? focused : hasSelection(this.dom, this.view.observer.selectionRange)",
319-
" let selectionNotFocus = !focused && !(this.view.state.facet(editable) || this.dom.tabIndex > -1) &&
320-
hasSelection(this.dom, this.view.observer.selectionRange) && !(activeElt && this.dom.contains(activeElt));",
321-
&format!("{CLIENT_PATH}/node_modules/@codemirror/view/dist/index.js")
322-
)?;
323314
// In [older
324315
// releases](https://www.tiny.cloud/docs/tinymce/5/6.0-upcoming-changes/#options),
325316
// TinyMCE allowed users to change `whitespace_elements`; the whitespace

client/package.json5

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@
4444
},
4545
type: 'module',
4646
version: '0.1.45',
47-
pnpm: {
48-
overrides: {
49-
'@codemirror/view': '<6.39.0',
50-
},
51-
},
5247
dependencies: {
5348
'@codemirror/commands': '^6.10.0',
5449
'@codemirror/lang-cpp': '^6.0.3',
@@ -66,7 +61,7 @@
6661
'@codemirror/lang-xml': '^6.1.0',
6762
'@codemirror/lang-yaml': '^6.1.2',
6863
'@codemirror/state': '^6.5.2',
69-
'@codemirror/view': '^6.38.8',
64+
'@codemirror/view': '^6.39.3',
7065
'@hpcc-js/wasm-graphviz': '^1.17.0',
7166
'@mathjax/mathjax-newcm-font': '4.0.0',
7267
codemirror: '^6.0.2',

client/pnpm-lock.yaml

Lines changed: 15 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/tests/overall_common/mod.rs

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,37 @@ use code_chat_editor::{
7676
// Not all messages produced by the server are ordered. To accommodate
7777
// out-of-order messages, this class provides a way to `insert` expected
7878
// messages, then wait until they're all be received (`assert_all_messages`).
79-
pub struct ExpectedMessages(HashMap<i64, EditorMessageContents>);
79+
pub struct ExpectedMessages(HashMap<i64, (EditorMessageContents, bool)>);
8080

8181
impl ExpectedMessages {
8282
pub fn new() -> ExpectedMessages {
8383
ExpectedMessages(HashMap::new())
8484
}
8585

86-
pub fn insert(&mut self, editor_message: EditorMessage) {
86+
pub fn insert(&mut self, editor_message: EditorMessage, is_dynamic: bool) {
8787
assert!(
8888
self.0
89-
.insert(editor_message.id as i64, editor_message.message)
89+
.insert(
90+
editor_message.id as i64,
91+
(editor_message.message, is_dynamic)
92+
)
9093
.is_none()
9194
);
9295
}
9396

9497
pub fn check(&mut self, editor_message: EditorMessage) {
95-
if let Some(editor_message_contents) = self.0.remove(&(editor_message.id as i64)) {
96-
assert_eq!(editor_message.message, editor_message_contents);
98+
if let Some((ref mut editor_message_contents, is_dynamic)) =
99+
self.0.remove(&(editor_message.id as i64))
100+
{
101+
if is_dynamic
102+
&& let EditorMessageContents::Update(emc) = editor_message_contents
103+
&& let Some(contents) = &mut emc.contents
104+
{
105+
let version = get_version(&editor_message);
106+
contents.version = version;
107+
}
108+
// Special case:
109+
assert_eq!(&editor_message.message, editor_message_contents);
97110
} else {
98111
panic!(
99112
"Message not found: looked for \n{:#?}\nin:\n{:#?}",
@@ -112,7 +125,14 @@ impl ExpectedMessages {
112125
timeout: Duration,
113126
) {
114127
while !self.0.is_empty() {
115-
self.check(codechat_server.get_message_timeout(timeout).await.unwrap());
128+
if let Some(editor_message) = codechat_server.get_message_timeout(timeout).await {
129+
self.check(editor_message);
130+
} else {
131+
panic!(
132+
"No matching messages found. Unmatched messages:\n{:#?}",
133+
self.0
134+
);
135+
}
116136
}
117137
}
118138
}
@@ -328,14 +348,20 @@ pub async fn perform_loadfile(
328348
.unwrap();
329349
// The ordering of these messages isn't fixed -- one can come first, or the
330350
// other.
331-
expected_messages.insert(EditorMessage {
332-
id: current_file_id,
333-
message: EditorMessageContents::Result(Ok(ResultOkTypes::Void)),
334-
});
335-
expected_messages.insert(EditorMessage {
336-
id: server_id,
337-
message: EditorMessageContents::LoadFile(path.clone()),
338-
});
351+
expected_messages.insert(
352+
EditorMessage {
353+
id: current_file_id,
354+
message: EditorMessageContents::Result(Ok(ResultOkTypes::Void)),
355+
},
356+
false,
357+
);
358+
expected_messages.insert(
359+
EditorMessage {
360+
id: server_id,
361+
message: EditorMessageContents::LoadFile(path.clone()),
362+
},
363+
false,
364+
);
339365
expected_messages
340366
.assert_all_messages(codechat_server, TIMEOUT)
341367
.await;
@@ -402,8 +428,8 @@ pub async fn get_empty_client_update(
402428
client_id: &mut f64,
403429
client_version: &mut f64,
404430
mode: &str,
405-
cursor_position: u32,
406-
scroll_position: f32,
431+
cursor_position: Option<u32>,
432+
scroll_position: Option<f32>,
407433
) {
408434
let msg = codechat_server.get_message_timeout(TIMEOUT).await.unwrap();
409435
let version = *client_version;
@@ -425,8 +451,8 @@ pub async fn get_empty_client_update(
425451
}),
426452
version: *client_version
427453
}),
428-
cursor_position: Some(cursor_position),
429-
scroll_position: Some(scroll_position)
454+
cursor_position,
455+
scroll_position
430456
})
431457
}
432458
);

server/tests/overall_core/mod.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -437,14 +437,20 @@ async fn test_server_core(
437437
.await
438438
.unwrap();
439439

440-
expected_messages.insert(EditorMessage {
441-
id: current_file_id,
442-
message: EditorMessageContents::Result(Ok(ResultOkTypes::Void)),
443-
});
444-
expected_messages.insert(EditorMessage {
445-
id: server_id,
446-
message: EditorMessageContents::LoadFile(txt_path.clone()),
447-
});
440+
expected_messages.insert(
441+
EditorMessage {
442+
id: current_file_id,
443+
message: EditorMessageContents::Result(Ok(ResultOkTypes::Void)),
444+
},
445+
false,
446+
);
447+
expected_messages.insert(
448+
EditorMessage {
449+
id: server_id,
450+
message: EditorMessageContents::LoadFile(txt_path.clone()),
451+
},
452+
false,
453+
);
448454
expected_messages
449455
.assert_all_messages(&codechat_server, TIMEOUT)
450456
.await;
@@ -943,8 +949,8 @@ async fn test_4_core(
943949
&mut client_id,
944950
&mut client_version,
945951
"python",
946-
3,
947-
1.0,
952+
Some(3),
953+
Some(1.0),
948954
)
949955
.await;
950956

@@ -955,8 +961,8 @@ async fn test_4_core(
955961
&mut client_id,
956962
&mut client_version,
957963
"python",
958-
5,
959-
1.0,
964+
Some(5),
965+
Some(1.0),
960966
)
961967
.await;
962968

@@ -1114,7 +1120,7 @@ async fn test_5_core(
11141120
doc: vec![StringDiff {
11151121
from: 0,
11161122
to: Some(8),
1117-
insert: "# Tesbart.\n".to_string(),
1123+
insert: "# foobarTest.\n".to_string(),
11181124
},],
11191125
doc_blocks: vec![],
11201126
version,

0 commit comments

Comments
 (0)