mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-10 03:10:41 +00:00
Fix handling of newline at end of content.
This commit is contained in:
parent
0a66978d7f
commit
bac285000d
@ -17,6 +17,8 @@ pub struct Chunk {
|
||||
/// If a chunk of text ends in a space, it can be compressed a bit.
|
||||
///
|
||||
/// (We can omit the space if it would result in a perfect fit.)
|
||||
///
|
||||
/// This only matches literally the ' ' byte.
|
||||
pub ends_with_space: bool,
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,11 @@ where
|
||||
if self.current_span >= self.source.spans().len() {
|
||||
// If this was the last chunk, return as is!
|
||||
// Well, make sure we don't end with a newline...
|
||||
let hard_stop = hard_stop || span_text.ends_with('\n');
|
||||
if span_text.ends_with('\n') {
|
||||
// This is basically a hard-stop here.
|
||||
// Easy, just remove 1 byte.
|
||||
segments.last_mut().unwrap().end -= 1;
|
||||
}
|
||||
|
||||
return Some(Chunk {
|
||||
width: total_width,
|
||||
|
Loading…
Reference in New Issue
Block a user