mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Use strongly typed CharIndex and ByteIndex + bug fixes (#8245)
Less risk of confusing the two. Found and fix a couple real bugs in the process! --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -604,7 +604,8 @@ impl Highlighter {
|
||||
}
|
||||
|
||||
#[cfg(feature = "syntect")]
|
||||
fn as_byte_range(whole: &str, range: &str) -> std::ops::Range<usize> {
|
||||
fn as_byte_range(whole: &str, range: &str) -> std::ops::Range<egui::text::ByteIndex> {
|
||||
use egui::text::ByteIndex;
|
||||
let whole_start = whole.as_ptr() as usize;
|
||||
let range_start = range.as_ptr() as usize;
|
||||
assert!(
|
||||
@@ -617,7 +618,7 @@ fn as_byte_range(whole: &str, range: &str) -> std::ops::Range<usize> {
|
||||
range_start + range.len()
|
||||
);
|
||||
let offset = range_start - whole_start;
|
||||
offset..(offset + range.len())
|
||||
ByteIndex(offset)..ByteIndex(offset + range.len())
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user