mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-24 01:46:31 +00:00
Fix ending newline problem
This commit is contained in:
parent
afb224b860
commit
4879d8cc71
@ -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,
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user