diff options
author | Christian Duerr <contact@christianduerr.com> | 2018-04-02 21:12:04 +0200 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2018-06-02 09:56:50 -0700 |
commit | 7f2fe5acb288d3533af5b95ac50162ed60c14042 (patch) | |
tree | 3b4138a01532088d8eab9ecae9bfa5619c5ab7dd /src | |
parent | 334d50e98c5f579e6f5b240ef2be971472ee27fb (diff) | |
download | alacritty-7f2fe5acb288d3533af5b95ac50162ed60c14042.tar.gz alacritty-7f2fe5acb288d3533af5b95ac50162ed60c14042.zip |
Add documentation to explain the process
Diffstat (limited to 'src')
-rw-r--r-- | src/grid/mod.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/grid/mod.rs b/src/grid/mod.rs index 0564cdf5..15ddf30e 100644 --- a/src/grid/mod.rs +++ b/src/grid/mod.rs @@ -747,25 +747,28 @@ impl<'a, T: Copy + 'a> Iterator for DisplayIter<'a, T> { #[inline] fn next(&mut self) -> Option<Self::Item> { - // Make sure indices are valid. Return None if we've reached the end. + // Check if the end of the line was reached let next_line = self.col == self.grid.num_cols(); if next_line { + // Return `None` if we've reached the end of the last line if self.offset == self.limit { return None; } + // Switch to the next line self.col = Column(0); self.offset -= 1; self.line = Line(*self.grid.lines - 1 - (self.offset - self.limit)); } - // Return the next item. + // Return the next item let item = Some(Indexed { inner: self.grid.raw[self.offset][self.col], line: self.line, column: self.col }); + // Only increment column if the line hasn't changed if !next_line { self.col += 1; } |