Location: crates/diffguard-lsp/src/text.rs lines 107 and 123
Problem: Two lossy usize to u32 casts on 64-bit targets:
Line 107: current_character_utf16.saturating_add(ch.len_utf16() as u32)
Line 123: text.chars().map(|ch| ch.len_utf16() as u32).sum()
ch.len_utf16() returns usize which can exceed u32::MAX on 64-bit targets with very long UTF-16 sequences. Silent truncation corrupts LSP character offset calculations.
Fix: Use u32::try_from() with fallible handling instead of as cast.
Clippy: cast_possible_truncation lint.
Location: crates/diffguard-lsp/src/text.rs lines 107 and 123
Problem: Two lossy usize to u32 casts on 64-bit targets:
Line 107: current_character_utf16.saturating_add(ch.len_utf16() as u32)
Line 123: text.chars().map(|ch| ch.len_utf16() as u32).sum()
ch.len_utf16() returns usize which can exceed u32::MAX on 64-bit targets with very long UTF-16 sequences. Silent truncation corrupts LSP character offset calculations.
Fix: Use u32::try_from() with fallible handling instead of as cast.
Clippy: cast_possible_truncation lint.