mirror of
https://github.com/typst/typst
synced 2025-08-24 03:34:14 +08:00
docs: update some comments
This commit is contained in:
parent
7dc3bcd8eb
commit
8e9e8a753c
@ -622,6 +622,7 @@ impl<T> LoadedAt<T> for Result<T, LoadError> {
|
||||
}
|
||||
|
||||
impl Loaded {
|
||||
/// Report an error, possibly in an external file.
|
||||
pub fn err_in_text(
|
||||
&self,
|
||||
pos: impl Into<ReportPos>,
|
||||
@ -629,10 +630,11 @@ impl Loaded {
|
||||
error: impl std::fmt::Display,
|
||||
) -> EcoVec<SourceDiagnostic> {
|
||||
let pos = pos.into();
|
||||
// This also does utf-8 validation. Only report an error in an external
|
||||
// file if it is human readable (valid utf-8), otherwise fall back to
|
||||
// `err_in_invalid_text`.
|
||||
let lines = Lines::from_bytes(&self.bytes);
|
||||
match (self.source.v, lines) {
|
||||
// Only report an error in an external file,
|
||||
// if it is human readable (valid utf-8).
|
||||
(LoadSource::Path(file_id), Ok(lines)) => {
|
||||
if let Some(range) = pos.range(&lines) {
|
||||
let span = Span::from_range(file_id, range);
|
||||
@ -664,7 +666,7 @@ impl Loaded {
|
||||
}
|
||||
}
|
||||
|
||||
/// Report an error, possibly in an external file.
|
||||
/// Report an error (possibly from an external file) that isn't valid utf-8.
|
||||
pub fn err_in_invalid_text(
|
||||
&self,
|
||||
pos: impl Into<ReportPos>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user