Fix ending newline problem

This commit is contained in:
Alexandre Bury 2018-01-11 00:16:13 +01:00
parent afb224b860
commit 4879d8cc71
2 changed files with 3 additions and 10 deletions

View File

@ -127,6 +127,9 @@ where
if self.current_span >= self.spans.len() { if self.current_span >= self.spans.len() {
// If this was the last chunk, return as is! // 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');
return Some(Chunk { return Some(Chunk {
width: total_width, width: total_width,
segments, segments,

View File

@ -9,7 +9,6 @@ use std::ops::Deref;
use std::sync::{Mutex, MutexGuard}; use std::sync::{Mutex, MutexGuard};
use std::sync::Arc; use std::sync::Arc;
use theme::Effect; use theme::Effect;
use unicode_width::UnicodeWidthStr;
use utils::lines::spans::{Row, SpanLinesIterator}; use utils::lines::spans::{Row, SpanLinesIterator};
use utils::markup::{Markup, MarkupText, StyledString}; use utils::markup::{Markup, MarkupText, StyledString};
use vec::Vec2; use vec::Vec2;
@ -194,15 +193,6 @@ pub struct TextView {
width: Option<usize>, width: Option<usize>,
} }
// If the last character is a newline, strip it.
fn strip_last_newline(content: &str) -> &str {
if content.ends_with('\n') {
&content[..content.len() - 1]
} else {
content
}
}
impl TextView { impl TextView {
/// Creates a new TextView with the given content. /// Creates a new TextView with the given content.
pub fn new<S>(content: S) -> Self pub fn new<S>(content: S) -> Self