Skip to content

fix search and replace all#86

Closed
tofpie wants to merge 1 commit intomicrosoft:mainfrom
tofpie:fix-issue-57
Closed

fix search and replace all#86
tofpie wants to merge 1 commit intomicrosoft:mainfrom
tofpie:fix-issue-57

Conversation

@tofpie
Copy link

@tofpie tofpie commented May 20, 2025

Fixes #57
Fixes #58

@tofpie
Copy link
Author

tofpie commented May 20, 2025

Probably not the most efficient fix, but, you get the idea!

@lhecker
Copy link
Member

lhecker commented May 20, 2025

That's indeed not exactly something I'd want to merge. The fact that this fixes the issue however means that there's a bug somewhere here, I believe:

edit/src/icu.rs

Lines 384 to 406 in c13b8ab

let index_contained = index_contained as usize;
let native_index = native_index as usize;
let double_cache = double_cache_from_utext(ut);
let dirty = ut.a != tb.generation() as i64;
if dirty {
// The text buffer contents have changed.
// Invalidate both caches so that future calls don't mistakenly use them
// when they enter the for loop in the else branch below (`dirty == false`).
double_cache.cache[0].utf16_len = 0;
double_cache.cache[1].utf16_len = 0;
double_cache.cache[0].utf8_range = 0..0;
double_cache.cache[1].utf8_range = 0..0;
ut.a = tb.generation() as i64;
} else {
// Check if one of the caches already contains the requested range.
for (i, cache) in double_cache.cache.iter_mut().enumerate() {
if cache.utf8_range.contains(&index_contained) {
double_cache.mru = i != 0;
return Some(cache);
}
}
}

Or it's because the ICU Regex instance doesn't get invalidated? #123 may have a better approach for this overall, but I'm not entirely sure yet what it is, given that #123 isn't correct yet either.

Copy link
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'll be blocking some PRs for "Request changes", so I can keep track of where I left notes on and which ones I still need to review.)

@lhecker
Copy link
Member

lhecker commented May 24, 2025

I had time to debug this and fixed it over in #258. Closing this PR. 🙂

@lhecker lhecker closed this May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deadlock during Search and Replace Search and replace is broken

2 participants