Wrap a bunch of traits for Unclipped<T>

This commit is contained in:
Julia 2022-11-21 11:47:46 -05:00
parent 1c84e77c37
commit 8c75df30cb
5 changed files with 81 additions and 13 deletions

View file

@ -131,9 +131,7 @@ impl LspCommand for PrepareRename {
if buffer.clip_point_utf16(start, Bias::Left) == start.0
&& buffer.clip_point_utf16(end, Bias::Left) == end.0
{
return Ok(Some(
buffer.anchor_after(start)..buffer.anchor_before(end),
));
return Ok(Some(buffer.anchor_after(start)..buffer.anchor_before(end)));
}
}
Ok(None)
@ -884,8 +882,7 @@ impl LspCommand for GetDocumentHighlights {
let end = buffer
.clip_point_utf16(point_from_lsp(lsp_highlight.range.end), Bias::Left);
DocumentHighlight {
range: buffer.anchor_after(start)
..buffer.anchor_before(end),
range: buffer.anchor_after(start)..buffer.anchor_before(end),
kind: lsp_highlight
.kind
.unwrap_or(lsp::DocumentHighlightKind::READ),
@ -1020,8 +1017,7 @@ impl LspCommand for GetHover {
let token_start =
buffer.clip_point_utf16(point_from_lsp(range.start), Bias::Left);
let token_end = buffer.clip_point_utf16(point_from_lsp(range.end), Bias::Left);
buffer.anchor_after(token_start)
..buffer.anchor_before(token_end)
buffer.anchor_after(token_start)..buffer.anchor_before(token_end)
})
});

View file

@ -25,8 +25,8 @@ use language::{
range_from_lsp, range_to_lsp, Anchor, Bias, Buffer, CachedLspAdapter, CharKind, CodeAction,
CodeLabel, Completion, Diagnostic, DiagnosticEntry, DiagnosticSet, Event as BufferEvent,
File as _, Language, LanguageRegistry, LanguageServerName, LocalFile, OffsetRangeExt,
Operation, Patch, PointUtf16, TextBufferSnapshot, ToOffset, ToPointUtf16,
Transaction, Unclipped,
Operation, Patch, PointUtf16, TextBufferSnapshot, ToOffset, ToPointUtf16, Transaction,
Unclipped,
};
use lsp::{
DiagnosticSeverity, DiagnosticTag, DocumentHighlightKind, LanguageServer, LanguageString,
@ -2660,7 +2660,7 @@ impl Project {
let mut sanitized_diagnostics = Vec::new();
let edits_since_save = Patch::new(
snapshot
.edits_since::<PointUtf16>(buffer.read(cx).saved_version())
.edits_since::<Unclipped<PointUtf16>>(buffer.read(cx).saved_version())
.collect(),
);
for entry in diagnostics {

View file

@ -500,7 +500,10 @@ impl LocalWorktree {
})
}
pub fn diagnostics_for_path(&self, path: &Path) -> Option<Vec<DiagnosticEntry<Unclipped<PointUtf16>>>> {
pub fn diagnostics_for_path(
&self,
path: &Path,
) -> Option<Vec<DiagnosticEntry<Unclipped<PointUtf16>>>> {
self.diagnostics.get(path).cloned()
}