WIP and merge
This commit is contained in:
parent
97f4406ef6
commit
1bdde8b2e4
584 changed files with 33536 additions and 17400 deletions
|
@ -2607,7 +2607,7 @@ impl MultiBuffer {
|
|||
return file.file_name(cx).to_string_lossy();
|
||||
}
|
||||
|
||||
if let Some(title) = self.buffer_based_title(buffer) {
|
||||
if let Some(title) = self.buffer_content_title(buffer) {
|
||||
return title;
|
||||
}
|
||||
};
|
||||
|
@ -2615,7 +2615,7 @@ impl MultiBuffer {
|
|||
"untitled".into()
|
||||
}
|
||||
|
||||
fn buffer_based_title(&self, buffer: &Buffer) -> Option<Cow<'_, str>> {
|
||||
fn buffer_content_title(&self, buffer: &Buffer) -> Option<Cow<'_, str>> {
|
||||
let mut is_leading_whitespace = true;
|
||||
let mut count = 0;
|
||||
let mut prev_was_space = false;
|
||||
|
@ -2647,11 +2647,11 @@ impl MultiBuffer {
|
|||
|
||||
let title = title.trim_end().to_string();
|
||||
|
||||
if !title.is_empty() {
|
||||
return Some(title.into());
|
||||
if title.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
None
|
||||
Some(title.into())
|
||||
}
|
||||
|
||||
pub fn set_title(&mut self, title: String, cx: &mut Context<Self>) {
|
||||
|
@ -4214,6 +4214,19 @@ impl MultiBufferSnapshot {
|
|||
self.diffs.values().any(|diff| !diff.is_empty())
|
||||
}
|
||||
|
||||
pub fn is_inside_word<T: ToOffset>(&self, position: T, for_completion: bool) -> bool {
|
||||
let position = position.to_offset(self);
|
||||
let classifier = self
|
||||
.char_classifier_at(position)
|
||||
.for_completion(for_completion);
|
||||
let next_char_kind = self.chars_at(position).next().map(|c| classifier.kind(c));
|
||||
let prev_char_kind = self
|
||||
.reversed_chars_at(position)
|
||||
.next()
|
||||
.map(|c| classifier.kind(c));
|
||||
prev_char_kind.zip(next_char_kind) == Some((CharKind::Word, CharKind::Word))
|
||||
}
|
||||
|
||||
pub fn surrounding_word<T: ToOffset>(
|
||||
&self,
|
||||
start: T,
|
||||
|
@ -7722,14 +7735,24 @@ impl<'a> Iterator for MultiBufferChunks<'a> {
|
|||
let diff_transform_end = diff_transform_end.min(self.range.end);
|
||||
|
||||
if diff_transform_end < chunk_end {
|
||||
let (before, after) =
|
||||
chunk.text.split_at(diff_transform_end - self.range.start);
|
||||
let split_idx = diff_transform_end - self.range.start;
|
||||
let (before, after) = chunk.text.split_at(split_idx);
|
||||
self.range.start = diff_transform_end;
|
||||
let mask = (1 << split_idx) - 1;
|
||||
let chars = chunk.chars & mask;
|
||||
let tabs = chunk.tabs & mask;
|
||||
|
||||
chunk.text = after;
|
||||
chunk.chars = chunk.chars >> split_idx;
|
||||
chunk.tabs = chunk.tabs >> split_idx;
|
||||
|
||||
// FIXME: We should be handling bitmap for tabs and chars here
|
||||
// Because we do a split at operation the bitmaps will be off
|
||||
|
||||
Some(Chunk {
|
||||
text: dbg!(before),
|
||||
text: before,
|
||||
chars,
|
||||
tabs,
|
||||
..chunk.clone()
|
||||
})
|
||||
} else {
|
||||
|
@ -7767,7 +7790,7 @@ impl<'a> Iterator for MultiBufferChunks<'a> {
|
|||
let chunk = if let Some(chunk) = chunks.next() {
|
||||
self.range.start += chunk.text.len();
|
||||
self.diff_base_chunks = Some((*buffer_id, chunks));
|
||||
dbg!(chunk)
|
||||
chunk
|
||||
} else {
|
||||
debug_assert!(has_trailing_newline);
|
||||
self.range.start += "\n".len();
|
||||
|
|
|
@ -3860,10 +3860,26 @@ fn test_random_chunk_bitmaps_with_diffs(cx: &mut App, mut rng: StdRng) {
|
|||
multibuffer.set_all_diff_hunks_expanded(cx);
|
||||
} else {
|
||||
let snapshot = multibuffer.snapshot(cx);
|
||||
let text = snapshot.text();
|
||||
|
||||
let mut ranges = Vec::new();
|
||||
for _ in 0..rng.gen_range(1..5) {
|
||||
let start = rng.gen_range(0..snapshot.len());
|
||||
let end = rng.gen_range(start..snapshot.len().min(start + 1000));
|
||||
if snapshot.len() == 0 {
|
||||
break;
|
||||
}
|
||||
|
||||
let diff_size = rng.gen_range(5..1000);
|
||||
let mut start = rng.gen_range(0..snapshot.len());
|
||||
|
||||
while !text.is_char_boundary(start) {
|
||||
start = start.saturating_sub(1);
|
||||
}
|
||||
|
||||
let mut end = rng.gen_range(start..snapshot.len().min(start + diff_size));
|
||||
|
||||
while !text.is_char_boundary(end) {
|
||||
end = end.saturating_add(1);
|
||||
}
|
||||
let start_anchor = snapshot.anchor_after(start);
|
||||
let end_anchor = snapshot.anchor_before(end);
|
||||
ranges.push(start_anchor..end_anchor);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue