Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/renderer/styled_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,21 @@ impl StyledBuffer {
/// If `line` does not exist in our buffer, adds empty lines up to the given
/// and fills the last line with unstyled whitespace.
pub(crate) fn puts(&mut self, line: usize, col: usize, string: &str, style: ElementStyle) {
if string.is_empty() {
// don't add trailing whitespace (from column offset) for blank strings
return;
}

self.ensure_lines(line);
let line = &mut self.lines[line];

let new_len = col + string.chars().count();
if new_len > line.len() {
line.resize(new_len, StyledChar::SPACE);
}

for (offset, chr) in string.chars().enumerate() {
let col = col + offset;
if col >= line.len() {
line.resize(col + 1, StyledChar::SPACE);
}
line[col] = StyledChar::new(chr, style);
}
}
Expand Down
Loading