Replace todo!s with stub calls to make Zed work
This commit is contained in:
parent
4c3c0eb796
commit
83f4320b60
1 changed files with 64 additions and 23 deletions
|
@ -6,7 +6,10 @@ use std::ops::{Add, AddAssign, Range, Sub};
|
||||||
use crate::MultiBufferSnapshot;
|
use crate::MultiBufferSnapshot;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
suggestion_map::{SuggestionEdit, SuggestionPoint, SuggestionSnapshot},
|
suggestion_map::{
|
||||||
|
SuggestionBufferRows, SuggestionChunks, SuggestionEdit, SuggestionOffset, SuggestionPoint,
|
||||||
|
SuggestionSnapshot,
|
||||||
|
},
|
||||||
TextHighlights,
|
TextHighlights,
|
||||||
};
|
};
|
||||||
use gpui::fonts::HighlightStyle;
|
use gpui::fonts::HighlightStyle;
|
||||||
|
@ -58,12 +61,11 @@ pub struct EditorAdditionPoint(pub Point);
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct EditorAdditionBufferRows<'a> {
|
pub struct EditorAdditionBufferRows<'a> {
|
||||||
_z: &'a std::marker::PhantomData<()>,
|
suggestion_rows: SuggestionBufferRows<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct EditorAdditionChunks<'a> {
|
pub struct EditorAdditionChunks<'a> {
|
||||||
_z: &'a std::marker::PhantomData<()>,
|
suggestion_chunks: SuggestionChunks<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -76,7 +78,7 @@ impl<'a> Iterator for EditorAdditionChunks<'a> {
|
||||||
type Item = Chunk<'a>;
|
type Item = Chunk<'a>;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
todo!("TODO kb")
|
self.suggestion_chunks.next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +86,7 @@ impl<'a> Iterator for EditorAdditionBufferRows<'a> {
|
||||||
type Item = Option<u32>;
|
type Item = Option<u32>;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
todo!("TODO kb")
|
self.suggestion_rows.next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,9 +125,15 @@ impl EditorAdditionMap {
|
||||||
snapshot.version += 1;
|
snapshot.version += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
let editor_addition_edits = Vec::new();
|
let mut editor_addition_edits = Vec::new();
|
||||||
{
|
for suggestion_edit in suggestion_edits {
|
||||||
todo!("TODO kb")
|
let old = suggestion_edit.old;
|
||||||
|
let new = suggestion_edit.new;
|
||||||
|
// TODO kb copied from suggestion_map
|
||||||
|
editor_addition_edits.push(EditorAdditionEdit {
|
||||||
|
old: EditorAdditionOffset(old.start.0)..EditorAdditionOffset(old.end.0),
|
||||||
|
new: EditorAdditionOffset(old.start.0)..EditorAdditionOffset(new.end.0),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
snapshot.suggestion_snapshot = suggestion_snapshot;
|
snapshot.suggestion_snapshot = suggestion_snapshot;
|
||||||
|
@ -140,47 +148,71 @@ impl EditorAdditionMap {
|
||||||
|
|
||||||
impl EditorAdditionSnapshot {
|
impl EditorAdditionSnapshot {
|
||||||
pub fn buffer_snapshot(&self) -> &MultiBufferSnapshot {
|
pub fn buffer_snapshot(&self) -> &MultiBufferSnapshot {
|
||||||
todo!("TODO kb")
|
// TODO kb copied from suggestion_map
|
||||||
|
self.suggestion_snapshot.buffer_snapshot()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_point(&self, offset: EditorAdditionOffset) -> EditorAdditionPoint {
|
pub fn to_point(&self, offset: EditorAdditionOffset) -> EditorAdditionPoint {
|
||||||
todo!("TODO kb")
|
// TODO kb copied from suggestion_map
|
||||||
|
self.to_editor_addition_point(
|
||||||
|
self.suggestion_snapshot
|
||||||
|
.to_point(super::suggestion_map::SuggestionOffset(offset.0)),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn max_point(&self) -> EditorAdditionPoint {
|
pub fn max_point(&self) -> EditorAdditionPoint {
|
||||||
todo!("TODO kb")
|
// TODO kb copied from suggestion_map
|
||||||
|
self.to_editor_addition_point(self.suggestion_snapshot.max_point())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_offset(&self, point: EditorAdditionPoint) -> EditorAdditionOffset {
|
pub fn to_offset(&self, point: EditorAdditionPoint) -> EditorAdditionOffset {
|
||||||
todo!("TODO kb")
|
// TODO kb copied from suggestion_map
|
||||||
|
EditorAdditionOffset(
|
||||||
|
self.suggestion_snapshot
|
||||||
|
.to_offset(self.to_suggestion_point(point, Bias::Left))
|
||||||
|
.0,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn chars_at(&self, start: EditorAdditionPoint) -> impl '_ + Iterator<Item = char> {
|
pub fn chars_at(&self, start: EditorAdditionPoint) -> impl '_ + Iterator<Item = char> {
|
||||||
Vec::new().into_iter()
|
self.suggestion_snapshot
|
||||||
|
.chars_at(self.to_suggestion_point(start, Bias::Left))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_suggestion_point(&self, point: EditorAdditionPoint, bias: Bias) -> SuggestionPoint {
|
// TODO kb what to do with bias?
|
||||||
todo!("TODO kb")
|
pub fn to_suggestion_point(&self, point: EditorAdditionPoint, _: Bias) -> SuggestionPoint {
|
||||||
|
SuggestionPoint(point.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_editor_addition_point(&self, point: SuggestionPoint) -> EditorAdditionPoint {
|
pub fn to_editor_addition_point(&self, point: SuggestionPoint) -> EditorAdditionPoint {
|
||||||
todo!("TODO kb")
|
EditorAdditionPoint(point.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clip_point(&self, point: EditorAdditionPoint, bias: Bias) -> EditorAdditionPoint {
|
pub fn clip_point(&self, point: EditorAdditionPoint, bias: Bias) -> EditorAdditionPoint {
|
||||||
todo!("TODO kb")
|
// TODO kb copied from suggestion_map
|
||||||
|
self.to_editor_addition_point(
|
||||||
|
self.suggestion_snapshot
|
||||||
|
.clip_point(self.to_suggestion_point(point, bias), bias),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn text_summary_for_range(&self, range: Range<EditorAdditionPoint>) -> TextSummary {
|
pub fn text_summary_for_range(&self, range: Range<EditorAdditionPoint>) -> TextSummary {
|
||||||
todo!("TODO kb")
|
// TODO kb copied from suggestion_map
|
||||||
|
self.suggestion_snapshot.text_summary_for_range(
|
||||||
|
self.to_suggestion_point(range.start, Bias::Left)
|
||||||
|
..self.to_suggestion_point(range.end, Bias::Left),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buffer_rows<'a>(&'a self, row: u32) -> EditorAdditionBufferRows<'a> {
|
pub fn buffer_rows<'a>(&'a self, row: u32) -> EditorAdditionBufferRows<'a> {
|
||||||
todo!("TODO kb")
|
EditorAdditionBufferRows {
|
||||||
|
suggestion_rows: self.suggestion_snapshot.buffer_rows(row),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn line_len(&self, row: u32) -> u32 {
|
pub fn line_len(&self, row: u32) -> u32 {
|
||||||
todo!("TODO kb")
|
// TODO kb copied from suggestion_map
|
||||||
|
self.suggestion_snapshot.line_len(row)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn chunks<'a>(
|
pub fn chunks<'a>(
|
||||||
|
@ -190,11 +222,20 @@ impl EditorAdditionSnapshot {
|
||||||
text_highlights: Option<&'a TextHighlights>,
|
text_highlights: Option<&'a TextHighlights>,
|
||||||
suggestion_highlight: Option<HighlightStyle>,
|
suggestion_highlight: Option<HighlightStyle>,
|
||||||
) -> EditorAdditionChunks<'a> {
|
) -> EditorAdditionChunks<'a> {
|
||||||
todo!("TODO kb")
|
// TODO kb copied from suggestion_map
|
||||||
|
EditorAdditionChunks {
|
||||||
|
suggestion_chunks: self.suggestion_snapshot.chunks(
|
||||||
|
SuggestionOffset(range.start.0)..SuggestionOffset(range.end.0),
|
||||||
|
language_aware,
|
||||||
|
text_highlights,
|
||||||
|
suggestion_highlight,
|
||||||
|
),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub fn text(&self) -> String {
|
pub fn text(&self) -> String {
|
||||||
todo!("TODO kb")
|
// TODO kb copied from suggestion_map
|
||||||
|
self.suggestion_snapshot.text()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue