pub trait ExcerptSourceResolver:
Send
+ Sync
+ Debug {
// Required methods
fn excerpt_source(
&self,
buffer: BufferId,
line: u32,
) -> Option<ExcerptSource>;
fn source_line(&self, source: BufferId, line: u32) -> Option<String>;
}Expand description
Answers where a line of a composed (multibuffer) buffer came from.
Introduced in OA.23.
A multibuffer shows excerpts of other files, so a consumer holding composed coordinates cannot say which file it is looking at. The agenda is the case that needs this: rewriting a headline in place propagates through the excerpt, but writing a planning line BELOW it targets a line the view does not contain — and the view is a synthetic buffer with no path of its own.
An abstract handle for the same reason ProjectResolver is one: the
plugin host must be able to answer the question without depending on
lattice-multibuffer, which sits above it. Whoever owns multibuffers
implements this and wires it in at boot; a host with none wired answers
None, which is the honest degradation rather than a panic.
Required Methods§
Sourcefn excerpt_source(&self, buffer: BufferId, line: u32) -> Option<ExcerptSource>
fn excerpt_source(&self, buffer: BufferId, line: u32) -> Option<ExcerptSource>
Where composed line of buffer came from.
None when buffer is not composed, when line is not source text (a
header or separator row belongs to the view, not to any file), or when
the source has no path. All three are ordinary answers: a caller asks
about the cursor’s line, and a cursor can be anywhere.
Sourcefn source_line(&self, source: BufferId, line: u32) -> Option<String>
fn source_line(&self, source: BufferId, line: u32) -> Option<String>
One line of a source document, without its trailing newline (slice OA.23b).
The read that pairs with acting on ExcerptSource::source. A caller
deciding what to write at the line below a headline has to see what is
there, and that line is outside every excerpt — so neither the composed
text nor a file read answers it. A file read is wrong twice over: it
misses edits the view has made and not yet saved.
source is an ExcerptSource::source, not an arbitrary buffer:
None for anything no view owns.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".