mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-02 21:44:34 +00:00
Update varinfo.rs
This commit is contained in:
parent
515b87b106
commit
ecd8ea6769
1 changed files with 10 additions and 1 deletions
|
@ -117,11 +117,20 @@ impl AbsLocation {
|
||||||
let reader = BufReader::new(file);
|
let reader = BufReader::new(file);
|
||||||
reader
|
reader
|
||||||
.lines()
|
.lines()
|
||||||
.nth(self.loc.ln_begin().map(|l| l - 1).unwrap_or(0) as usize)
|
.nth(
|
||||||
|
self.loc
|
||||||
|
.ln_begin()
|
||||||
|
.map(|l| l.saturating_sub(1))
|
||||||
|
.unwrap_or(0) as usize,
|
||||||
|
)
|
||||||
.and_then(|res| {
|
.and_then(|res| {
|
||||||
let res = res.ok()?;
|
let res = res.ok()?;
|
||||||
let begin = self.loc.col_begin().unwrap_or(0) as usize;
|
let begin = self.loc.col_begin().unwrap_or(0) as usize;
|
||||||
let end = self.loc.col_end().unwrap_or(0) as usize;
|
let end = self.loc.col_end().unwrap_or(0) as usize;
|
||||||
|
if begin > end {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let end = end.min(res.len());
|
||||||
let res = res[begin..end].to_string();
|
let res = res[begin..end].to_string();
|
||||||
Some(res)
|
Some(res)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue