Fixup compile errors
This commit is contained in:
parent
8c75df30cb
commit
e51cbf67ab
11 changed files with 83 additions and 103 deletions
|
@ -253,7 +253,7 @@ pub struct Symbol {
|
|||
pub label: CodeLabel,
|
||||
pub name: String,
|
||||
pub kind: lsp::SymbolKind,
|
||||
pub range: Range<PointUtf16>,
|
||||
pub range: Range<Unclipped<PointUtf16>>,
|
||||
pub signature: [u8; 32],
|
||||
}
|
||||
|
||||
|
@ -2682,9 +2682,9 @@ impl Project {
|
|||
// Expand empty ranges by one codepoint
|
||||
if range.start == range.end {
|
||||
// This will be go to the next boundary when being clipped
|
||||
range.end.column += 1;
|
||||
if range.start == range.end && range.end.column > 0 {
|
||||
range.start.column -= 1;
|
||||
range.end.0.column += 1;
|
||||
if range.start == range.end && range.end.0.column > 0 {
|
||||
range.start.0.column -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3287,7 +3287,7 @@ impl Project {
|
|||
return Task::ready(Ok(Default::default()));
|
||||
};
|
||||
|
||||
let position = position.to_point_utf16(source_buffer);
|
||||
let position = Unclipped(position.to_point_utf16(source_buffer));
|
||||
let anchor = source_buffer.anchor_after(position);
|
||||
|
||||
if worktree.read(cx).as_local().is_some() {
|
||||
|
@ -3306,7 +3306,7 @@ impl Project {
|
|||
lsp::TextDocumentIdentifier::new(
|
||||
lsp::Url::from_file_path(buffer_abs_path).unwrap(),
|
||||
),
|
||||
point_to_lsp(position),
|
||||
point_to_lsp(position.0),
|
||||
),
|
||||
context: Default::default(),
|
||||
work_done_progress_params: Default::default(),
|
||||
|
@ -3349,7 +3349,7 @@ impl Project {
|
|||
let range = range_from_lsp(edit.range);
|
||||
let start = snapshot.clip_point_utf16(range.start, Bias::Left);
|
||||
let end = snapshot.clip_point_utf16(range.end, Bias::Left);
|
||||
if start != range.start || end != range.end {
|
||||
if start != range.start.0 || end != range.end.0 {
|
||||
log::info!("completion out of expected range");
|
||||
return None;
|
||||
}
|
||||
|
@ -3361,13 +3361,13 @@ impl Project {
|
|||
// If the language server does not provide a range, then infer
|
||||
// the range based on the syntax tree.
|
||||
None => {
|
||||
if position != clipped_position {
|
||||
if position.0 != clipped_position {
|
||||
log::info!("completion out of expected range");
|
||||
return None;
|
||||
}
|
||||
let Range { start, end } = range_for_token
|
||||
.get_or_insert_with(|| {
|
||||
let offset = position.to_offset_clipped(&snapshot);
|
||||
let offset = position.to_offset(&snapshot);
|
||||
let (range, kind) = snapshot.surrounding_word(offset);
|
||||
if kind == Some(CharKind::Word) {
|
||||
range
|
||||
|
@ -5116,22 +5116,30 @@ impl Project {
|
|||
_: Arc<Client>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<proto::GetCompletionsResponse> {
|
||||
let position = envelope
|
||||
.payload
|
||||
.position
|
||||
.and_then(language::proto::deserialize_anchor)
|
||||
.ok_or_else(|| anyhow!("invalid position"))?;
|
||||
let version = deserialize_version(envelope.payload.version);
|
||||
let buffer = this.read_with(&cx, |this, cx| {
|
||||
this.opened_buffers
|
||||
.get(&envelope.payload.buffer_id)
|
||||
.and_then(|buffer| buffer.upgrade(cx))
|
||||
.ok_or_else(|| anyhow!("unknown buffer id {}", envelope.payload.buffer_id))
|
||||
})?;
|
||||
|
||||
let position = envelope
|
||||
.payload
|
||||
.position
|
||||
.and_then(language::proto::deserialize_anchor)
|
||||
.map(|p| {
|
||||
buffer.read_with(&cx, |buffer, _| {
|
||||
buffer.clip_point_utf16(Unclipped(p.to_point_utf16(buffer)), Bias::Left)
|
||||
})
|
||||
})
|
||||
.ok_or_else(|| anyhow!("invalid position"))?;
|
||||
|
||||
let version = deserialize_version(envelope.payload.version);
|
||||
buffer
|
||||
.update(&mut cx, |buffer, _| buffer.wait_for_version(version))
|
||||
.await;
|
||||
let version = buffer.read_with(&cx, |buffer, _| buffer.version());
|
||||
|
||||
let completions = this
|
||||
.update(&mut cx, |this, cx| this.completions(&buffer, position, cx))
|
||||
.await?;
|
||||
|
@ -5618,8 +5626,8 @@ impl Project {
|
|||
},
|
||||
|
||||
name: serialized_symbol.name,
|
||||
range: PointUtf16::new(start.row, start.column)
|
||||
..PointUtf16::new(end.row, end.column),
|
||||
range: Unclipped(PointUtf16::new(start.row, start.column))
|
||||
..Unclipped(PointUtf16::new(end.row, end.column)),
|
||||
kind,
|
||||
signature: serialized_symbol
|
||||
.signature
|
||||
|
@ -5705,10 +5713,10 @@ impl Project {
|
|||
|
||||
let mut lsp_edits = lsp_edits.into_iter().peekable();
|
||||
let mut edits = Vec::new();
|
||||
while let Some((mut range, mut new_text)) = lsp_edits.next() {
|
||||
while let Some((range, mut new_text)) = lsp_edits.next() {
|
||||
// Clip invalid ranges provided by the language server.
|
||||
range.start = snapshot.clip_point_utf16(range.start, Bias::Left);
|
||||
range.end = snapshot.clip_point_utf16(range.end, Bias::Left);
|
||||
let mut range = snapshot.clip_point_utf16(range.start, Bias::Left)
|
||||
..snapshot.clip_point_utf16(range.end, Bias::Left);
|
||||
|
||||
// Combine any LSP edits that are adjacent.
|
||||
//
|
||||
|
@ -5720,11 +5728,11 @@ impl Project {
|
|||
// In order for the diffing logic below to work properly, any edits that
|
||||
// cancel each other out must be combined into one.
|
||||
while let Some((next_range, next_text)) = lsp_edits.peek() {
|
||||
if next_range.start > range.end {
|
||||
if next_range.start.row > range.end.row + 1
|
||||
|| next_range.start.column > 0
|
||||
if next_range.start.0 > range.end {
|
||||
if next_range.start.0.row > range.end.row + 1
|
||||
|| next_range.start.0.column > 0
|
||||
|| snapshot.clip_point_utf16(
|
||||
PointUtf16::new(range.end.row, u32::MAX),
|
||||
Unclipped(PointUtf16::new(range.end.row, u32::MAX)),
|
||||
Bias::Left,
|
||||
) > range.end
|
||||
{
|
||||
|
@ -5732,7 +5740,7 @@ impl Project {
|
|||
}
|
||||
new_text.push('\n');
|
||||
}
|
||||
range.end = next_range.end;
|
||||
range.end = snapshot.clip_point_utf16(next_range.end, Bias::Left);
|
||||
new_text.push_str(next_text);
|
||||
lsp_edits.next();
|
||||
}
|
||||
|
@ -5741,8 +5749,8 @@ impl Project {
|
|||
// we can identify the changes more precisely, preserving the locations
|
||||
// of any anchors positioned in the unchanged regions.
|
||||
if range.end.row > range.start.row {
|
||||
let mut offset = range.start.to_offset_clipped(&snapshot);
|
||||
let old_text = snapshot.text_for_clamped_range(range).collect::<String>();
|
||||
let mut offset = range.start.to_offset(&snapshot);
|
||||
let old_text = snapshot.text_for_range(range).collect::<String>();
|
||||
|
||||
let diff = TextDiff::from_lines(old_text.as_str(), &new_text);
|
||||
let mut moved_since_edit = true;
|
||||
|
@ -6053,13 +6061,13 @@ fn serialize_symbol(symbol: &Symbol) -> proto::Symbol {
|
|||
path: symbol.path.path.to_string_lossy().to_string(),
|
||||
name: symbol.name.clone(),
|
||||
kind: unsafe { mem::transmute(symbol.kind) },
|
||||
start: Some(proto::Point {
|
||||
row: symbol.range.start.row,
|
||||
column: symbol.range.start.column,
|
||||
start: Some(proto::UnclippedPoint {
|
||||
row: symbol.range.start.0.row,
|
||||
column: symbol.range.start.0.column,
|
||||
}),
|
||||
end: Some(proto::Point {
|
||||
row: symbol.range.end.row,
|
||||
column: symbol.range.end.column,
|
||||
end: Some(proto::UnclippedPoint {
|
||||
row: symbol.range.end.0.row,
|
||||
column: symbol.range.end.0.column,
|
||||
}),
|
||||
signature: symbol.signature.to_vec(),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue