Use stable rust
This commit is contained in:
parent
31993762de
commit
c2144a2634
18 changed files with 118 additions and 44 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
name = "reconcile-text"
|
name = "reconcile-text"
|
||||||
description = "Intelligent 3-way text merging with automated conflict resolution"
|
description = "Intelligent 3-way text merging with automated conflict resolution"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
rust-version = "1.85"
|
rust-version = "1.94"
|
||||||
authors = ["Andras Schmelczer <andras@schmelczer.dev>"]
|
authors = ["Andras Schmelczer <andras@schmelczer.dev>"]
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
@ -69,7 +69,7 @@ missing_debug_implementations = "warn"
|
||||||
[lints.clippy]
|
[lints.clippy]
|
||||||
await_holding_lock = "warn"
|
await_holding_lock = "warn"
|
||||||
dbg_macro = "warn"
|
dbg_macro = "warn"
|
||||||
empty_enum = "warn"
|
empty_enums = "warn"
|
||||||
enum_glob_use = "warn"
|
enum_glob_use = "warn"
|
||||||
exit = "warn"
|
exit = "warn"
|
||||||
filter_map_next = "warn"
|
filter_map_next = "warn"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
name = "reconcile-text-python"
|
name = "reconcile-text-python"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.85"
|
rust-version = "1.94"
|
||||||
authors = ["Andras Schmelczer <andras@schmelczer.dev>"]
|
authors = ["Andras Schmelczer <andras@schmelczer.dev>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2025-06-06"
|
channel = "1.94.0"
|
||||||
targets = [ "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl" ]
|
targets = [ "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl" ]
|
||||||
profile = "default"
|
profile = "default"
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1 @@
|
||||||
imports_granularity = "crate"
|
|
||||||
condense_wildcard_suffixes = true
|
|
||||||
fn_single_line = true
|
|
||||||
format_strings = true
|
|
||||||
reorder_impl_items = true
|
|
||||||
group_imports = "StdExternalCrate"
|
|
||||||
use_field_init_shorthand = true
|
use_field_init_shorthand = true
|
||||||
wrap_comments=true
|
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,7 @@ where
|
||||||
order: last_equal_order,
|
order: last_equal_order,
|
||||||
length: last_equal_length,
|
length: last_equal_length,
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
text: last_equal_text,
|
text: last_equal_text,
|
||||||
..
|
..
|
||||||
}),
|
}),
|
||||||
) => {
|
) => {
|
||||||
|
|
@ -342,7 +342,8 @@ where
|
||||||
// matching (order, length) means they cover the same substring
|
// matching (order, length) means they cover the same substring
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
debug_assert_eq!(
|
debug_assert_eq!(
|
||||||
text, last_equal_text,
|
text,
|
||||||
|
last_equal_text,
|
||||||
"Equal operations with same order and length should have the same text, \
|
"Equal operations with same order and length should have the same text, \
|
||||||
but got {operation:?} vs {:?}",
|
but got {operation:?} vs {:?}",
|
||||||
Operation::<T>::Equal {
|
Operation::<T>::Equal {
|
||||||
|
|
@ -438,7 +439,9 @@ impl<T> Debug for Operation<T>
|
||||||
where
|
where
|
||||||
T: PartialEq + Clone + Debug,
|
T: PartialEq + Clone + Debug,
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{self}") }
|
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||||
|
write!(f, "{self}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,9 @@ impl<T> RawOperation<T>
|
||||||
where
|
where
|
||||||
T: PartialEq + Clone + Debug,
|
T: PartialEq + Clone + Debug,
|
||||||
{
|
{
|
||||||
pub fn vec_from(left: &[Token<T>], right: &[Token<T>]) -> Vec<Self> { myers_diff(left, right) }
|
pub fn vec_from(left: &[Token<T>], right: &[Token<T>]) -> Vec<Self> {
|
||||||
|
myers_diff(left, right)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn tokens(&self) -> &[Token<T>] {
|
pub fn tokens(&self) -> &[Token<T>] {
|
||||||
match self {
|
match self {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
---
|
---
|
||||||
source: src/tokenizer/line_tokenizer.rs
|
source: src/tokenizer/line_tokenizer.rs
|
||||||
assertion_line: 78
|
|
||||||
expression: "line_tokenizer(\"Mixed\\r\\nand\\rbare\")"
|
expression: "line_tokenizer(\"Mixed\\r\\nand\\rbare\")"
|
||||||
---
|
---
|
||||||
[
|
[
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
---
|
---
|
||||||
source: src/tokenizer/markdown_tokenizer.rs
|
source: src/tokenizer/markdown_tokenizer.rs
|
||||||
assertion_line: 199
|
|
||||||
expression: "markdown_tokenizer(\"## Sub heading\")"
|
expression: "markdown_tokenizer(\"## Sub heading\")"
|
||||||
---
|
---
|
||||||
[
|
[
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
---
|
||||||
|
source: src/tokenizer/markdown_tokenizer.rs
|
||||||
|
expression: "markdown_tokenizer(\"###### Deep heading\")"
|
||||||
|
---
|
||||||
|
[
|
||||||
|
Token {
|
||||||
|
normalized: "###### Deep",
|
||||||
|
original: "###### Deep",
|
||||||
|
is_left_joinable: false,
|
||||||
|
is_right_joinable: true,
|
||||||
|
},
|
||||||
|
Token {
|
||||||
|
normalized: " heading",
|
||||||
|
original: " ",
|
||||||
|
is_left_joinable: true,
|
||||||
|
is_right_joinable: true,
|
||||||
|
},
|
||||||
|
Token {
|
||||||
|
normalized: "heading",
|
||||||
|
original: "heading",
|
||||||
|
is_left_joinable: true,
|
||||||
|
is_right_joinable: true,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
@ -30,7 +30,9 @@ where
|
||||||
/// Trivial implementation of Token when the normalized form is the same as the
|
/// Trivial implementation of Token when the normalized form is the same as the
|
||||||
/// original string
|
/// original string
|
||||||
impl From<&str> for Token<String> {
|
impl From<&str> for Token<String> {
|
||||||
fn from(text: &str) -> Self { Token::new(text.to_owned(), text.to_owned(), true, true) }
|
fn from(text: &str) -> Self {
|
||||||
|
Token::new(text.to_owned(), text.to_owned(), true, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Token<T>
|
impl<T> Token<T>
|
||||||
|
|
@ -51,18 +53,28 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn original(&self) -> &str { &self.original }
|
pub fn original(&self) -> &str {
|
||||||
|
&self.original
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_normalized(&mut self, normalized: T) { self.normalized = normalized; }
|
pub fn set_normalized(&mut self, normalized: T) {
|
||||||
|
self.normalized = normalized;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn normalized(&self) -> &T { &self.normalized }
|
pub fn normalized(&self) -> &T {
|
||||||
|
&self.normalized
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_original_length(&self) -> usize { self.original.chars().count() }
|
pub fn get_original_length(&self) -> usize {
|
||||||
|
self.original.chars().count()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> PartialEq for Token<T>
|
impl<T> PartialEq for Token<T>
|
||||||
where
|
where
|
||||||
T: PartialEq + Clone + Debug,
|
T: PartialEq + Clone + Debug,
|
||||||
{
|
{
|
||||||
fn eq(&self, other: &Self) -> bool { self.normalized == other.normalized }
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.normalized == other.normalized
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,9 @@ pub struct CursorPosition {
|
||||||
impl CursorPosition {
|
impl CursorPosition {
|
||||||
#[cfg_attr(feature = "wasm", wasm_bindgen(constructor))]
|
#[cfg_attr(feature = "wasm", wasm_bindgen(constructor))]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(id: usize, char_index: usize) -> Self { Self { id, char_index } }
|
pub fn new(id: usize, char_index: usize) -> Self {
|
||||||
|
Self { id, char_index }
|
||||||
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_index(&self, index: usize) -> Self {
|
pub fn with_index(&self, index: usize) -> Self {
|
||||||
|
|
@ -29,9 +31,13 @@ impl CursorPosition {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn id(&self) -> usize { self.id }
|
pub fn id(&self) -> usize {
|
||||||
|
self.id
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "wasm", wasm_bindgen(js_name = characterIndex))]
|
#[cfg_attr(feature = "wasm", wasm_bindgen(js_name = characterIndex))]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn char_index(&self) -> usize { self.char_index }
|
pub fn char_index(&self) -> usize {
|
||||||
|
self.char_index
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,19 +62,27 @@ impl From<NumberOrText> for JsValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<i64> for NumberOrText {
|
impl From<i64> for NumberOrText {
|
||||||
fn from(value: i64) -> Self { NumberOrText::Number(value) }
|
fn from(value: i64) -> Self {
|
||||||
|
NumberOrText::Number(value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<String> for NumberOrText {
|
impl From<String> for NumberOrText {
|
||||||
fn from(value: String) -> Self { NumberOrText::Text(value) }
|
fn from(value: String) -> Self {
|
||||||
|
NumberOrText::Text(value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&str> for NumberOrText {
|
impl From<&str> for NumberOrText {
|
||||||
fn from(value: &str) -> Self { NumberOrText::Text(value.to_owned()) }
|
fn from(value: &str) -> Self {
|
||||||
|
NumberOrText::Text(value.to_owned())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<Cow<'a, str>> for NumberOrText {
|
impl<'a> From<Cow<'a, str>> for NumberOrText {
|
||||||
fn from(value: Cow<'a, str>) -> Self { NumberOrText::Text(value.into_owned()) }
|
fn from(value: Cow<'a, str>) -> Self {
|
||||||
|
NumberOrText::Text(value.into_owned())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error type for deserialisation failures
|
/// Error type for deserialisation failures
|
||||||
|
|
@ -105,5 +113,7 @@ impl std::error::Error for DeserialisationError {}
|
||||||
|
|
||||||
#[cfg(feature = "wasm")]
|
#[cfg(feature = "wasm")]
|
||||||
impl From<DeserialisationError> for JsValue {
|
impl From<DeserialisationError> for JsValue {
|
||||||
fn from(error: DeserialisationError) -> Self { JsValue::from_str(&error.message) }
|
fn from(error: DeserialisationError) -> Self {
|
||||||
|
JsValue::from_str(&error.message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,17 @@ pub struct SpanWithHistory {
|
||||||
#[cfg_attr(feature = "wasm", wasm_bindgen)]
|
#[cfg_attr(feature = "wasm", wasm_bindgen)]
|
||||||
impl SpanWithHistory {
|
impl SpanWithHistory {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(text: String, history: History) -> Self { SpanWithHistory { text, history } }
|
pub fn new(text: String, history: History) -> Self {
|
||||||
|
SpanWithHistory { text, history }
|
||||||
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn history(&self) -> History { self.history }
|
pub fn history(&self) -> History {
|
||||||
|
self.history
|
||||||
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn text(&self) -> String { self.text.clone() }
|
pub fn text(&self) -> String {
|
||||||
|
self.text.clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,15 +33,21 @@ impl TextWithCursors {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn text(&self) -> String { self.text.to_string() }
|
pub fn text(&self) -> String {
|
||||||
|
self.text.clone()
|
||||||
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn cursors(&self) -> Vec<CursorPosition> { self.cursors.clone() }
|
pub fn cursors(&self) -> Vec<CursorPosition> {
|
||||||
|
self.cursors.clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TextWithCursors {
|
impl TextWithCursors {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn text_ref(&self) -> &str { &self.text }
|
pub fn text_ref(&self) -> &str {
|
||||||
|
&self.text
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<&'a str> for TextWithCursors {
|
impl<'a> From<&'a str> for TextWithCursors {
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,9 @@ impl V {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn len(&self) -> usize { self.v.len() }
|
fn len(&self) -> usize {
|
||||||
|
self.v.len()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Index<isize> for V {
|
impl Index<isize> for V {
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,9 @@ impl StringBuilder<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Insert a string at the end of the built buffer
|
/// Insert a string at the end of the built buffer
|
||||||
pub fn insert(&mut self, text: &str) { self.buffer.push_str(text); }
|
pub fn insert(&mut self, text: &str) {
|
||||||
|
self.buffer.push_str(text);
|
||||||
|
}
|
||||||
|
|
||||||
/// Skip copying `length` characters from the original string to the built
|
/// Skip copying `length` characters from the original string to the built
|
||||||
/// buffer
|
/// buffer
|
||||||
|
|
@ -64,7 +66,9 @@ impl StringBuilder<'_> {
|
||||||
|
|
||||||
/// Returns the currently built buffer and clears it to allow consuming
|
/// Returns the currently built buffer and clears it to allow consuming
|
||||||
/// the result incrementally.
|
/// the result incrementally.
|
||||||
pub fn take(&mut self) -> String { std::mem::take(&mut self.buffer) }
|
pub fn take(&mut self) -> String {
|
||||||
|
std::mem::take(&mut self.buffer)
|
||||||
|
}
|
||||||
|
|
||||||
/// Get a slice of the remaining original string. The slice starts from
|
/// Get a slice of the remaining original string. The slice starts from
|
||||||
/// where the next delete/retain operation would start and is of length
|
/// where the next delete/retain operation would start and is of length
|
||||||
|
|
|
||||||
12
src/wasm.rs
12
src/wasm.rs
|
|
@ -139,13 +139,19 @@ pub struct TextWithCursorsAndHistory {
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
impl TextWithCursorsAndHistory {
|
impl TextWithCursorsAndHistory {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn text(&self) -> String { self.text_with_cursors.text() }
|
pub fn text(&self) -> String {
|
||||||
|
self.text_with_cursors.text()
|
||||||
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn cursors(&self) -> Vec<CursorPosition> { self.text_with_cursors.cursors() }
|
pub fn cursors(&self) -> Vec<CursorPosition> {
|
||||||
|
self.text_with_cursors.cursors()
|
||||||
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn history(&self) -> Vec<SpanWithHistory> { self.history.clone() }
|
pub fn history(&self) -> Vec<SpanWithHistory> {
|
||||||
|
self.history.clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the UTF8 parsed string if it's a text, or `None` if it's likely
|
/// Returns the UTF8 parsed string if it's a text, or `None` if it's likely
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,9 @@ pub struct ExampleDocument {
|
||||||
|
|
||||||
impl ExampleDocument {
|
impl ExampleDocument {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn parent(&self) -> String { self.parent.clone() }
|
pub fn parent(&self) -> String {
|
||||||
|
self.parent.clone()
|
||||||
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn left(&self) -> TextWithCursors {
|
pub fn left(&self) -> TextWithCursors {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue