first pass of merging in warp (doesn't build)

This commit is contained in:
Ryan Ward
2026-07-01 16:08:58 -05:00
parent 2f64909469
commit 4770ac06b5
3662 changed files with 414574 additions and 89772 deletions
+23 -21
View File
@@ -11,31 +11,24 @@
//! optimizations rely on fast substring searches (like highly-optimized platform-specific
//! `memchr` implementations) that we can't use with a non-contiguous buffer.
use std::{borrow::Cow, future::Future};
use std::borrow::Cow;
use std::future::Future;
use anyhow::{Context, bail};
use rangemap::RangeSet;
use regex_automata::{
Anchored, Input, MatchError, MatchKind,
hybrid::{
BuildError, LazyStateID,
dfa::{Cache, DFA},
},
nfa::thompson,
util::syntax::Config,
};
use regex_automata::hybrid::dfa::{Cache, DFA};
use regex_automata::hybrid::{BuildError, LazyStateID};
use regex_automata::nfa::thompson;
use regex_automata::util::syntax::Config;
use regex_automata::{Anchored, Input, MatchError, MatchKind};
use string_offset::CharOffset;
use sum_tree::SumTree;
use string_offset::CharOffset;
use super::buffer::Buffer;
use super::cursor::BufferCursor;
use super::text::{BufferSummary, BufferText};
use crate::search::RestorableSearchResults;
use super::{
buffer::Buffer,
cursor::BufferCursor,
text::{BufferSummary, BufferText},
};
#[cfg(test)]
#[path = "find_tests.rs"]
mod tests;
@@ -199,7 +192,7 @@ impl Engine {
buffer: &SumTree<BufferText>,
buffer_offset: CharOffset,
) -> anyhow::Result<Vec<Match>> {
galaxyui::r#async::block_on(self.find(buffer, buffer_offset))
galaxyui_core::r#async::block_on(self.find(buffer, buffer_offset))
}
/// Find all matches for this pattern in the given slice of content.
@@ -253,7 +246,7 @@ impl Engine {
log::warn!("Forward DFA found a match end, but reverse DFA did not find a start");
}
// Because we seeked to the left of the match end, move to the next item after the
// Because we sought to the left of the match end, move to the next item after the
// match to prevent an infinite loop.
buffer_cursor.next_char_position();
@@ -319,7 +312,16 @@ impl Engine {
}
} else if let Some(character) = cursor.char() {
let mut bytes = [0u8; 4];
for byte in character.encode_utf8(&mut bytes).bytes() {
let encoded = character.encode_utf8(&mut bytes).len();
let utf8 = &mut bytes[..encoded];
// The reverse DFA was compiled over the reversed byte stream, so a
// multi-byte character's bytes must be fed to it back-to-front.
// Single-byte (ASCII) characters are unaffected, which is why the bug
// only surfaced for non-ASCII (e.g. CJK) queries.
if matches!(direction, SearchDirection::Reverse) {
utf8.reverse();
}
for &byte in utf8.iter() {
state = dfa
.next_state(cache, state, byte)
.context("Couldn't advance to next state")?;