Fix tests
This commit is contained in:
parent
210ca61f13
commit
00bc4d1e88
4 changed files with 16 additions and 8 deletions
|
|
@ -86,7 +86,7 @@ impl<'a> LayoutRun<'a> {
|
|||
x_end = Some(self.glyphs.last().map_or(0., |glyph| glyph.x + glyph.w * ltr_factor));
|
||||
}
|
||||
if let Some(x_start) = x_start {
|
||||
let x_end = x_end.unwrap();
|
||||
let x_end = x_end.expect("end of cursor not found");
|
||||
let (x_start, x_end) = if x_start < x_end { (x_start, x_end) } else { (x_end, x_start) };
|
||||
Some((x_start, x_end - x_start))
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::string::{String, ToString};
|
||||
use core::cmp;
|
||||
use std::iter::once;
|
||||
use alloc::string::String;
|
||||
use core::{cmp, iter::once};
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
use crate::{Action, AttrsList, Buffer, BufferLine, Cursor, Edit, LayoutCursor};
|
||||
|
|
@ -227,7 +226,7 @@ impl<'a> Edit<'a> for Editor<'a> {
|
|||
if let Some(data_line) = lines_iter.next() {
|
||||
let mut these_attrs = final_attrs.split_off(data_line.len());
|
||||
remaining_split_len -= data_line.len();
|
||||
std::mem::swap(&mut these_attrs, &mut final_attrs);
|
||||
core::mem::swap(&mut these_attrs, &mut final_attrs);
|
||||
line.append(BufferLine::new(data_line.strip_suffix(char::is_control).unwrap_or(data_line), these_attrs));
|
||||
} else {
|
||||
panic!("str::lines() did not yield any elements");
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ use crate::{
|
|||
Edit,
|
||||
Editor,
|
||||
Style,
|
||||
Weight,
|
||||
Weight,
|
||||
Wrap,
|
||||
};
|
||||
|
||||
|
|
@ -161,7 +161,7 @@ impl<'a> Edit<'a> for SyntaxEditor<'a> {
|
|||
fn select_opt(&self) -> Option<Cursor> {
|
||||
self.editor.select_opt()
|
||||
}
|
||||
|
||||
|
||||
fn set_select_opt(&mut self, select_opt: Option<Cursor>) {
|
||||
self.editor.set_select_opt(select_opt);
|
||||
}
|
||||
|
|
@ -247,7 +247,7 @@ impl<'a> Edit<'a> for SyntaxEditor<'a> {
|
|||
if highlighted > 0 {
|
||||
buffer.set_redraw(true);
|
||||
#[cfg(feature = "std")]
|
||||
log::debug!("Syntax highlighted {} lines in {:?}", highlighted, now.elapsed());
|
||||
log::debug!("Syntax highlighted {} lines in {:?}", highlighted, now.elapsed());
|
||||
}
|
||||
|
||||
self.editor.shape_as_needed();
|
||||
|
|
@ -261,6 +261,10 @@ impl<'a> Edit<'a> for SyntaxEditor<'a> {
|
|||
self.editor.delete_selection()
|
||||
}
|
||||
|
||||
fn insert_string(&mut self, data: &str, attrs_list: Option<AttrsList>) {
|
||||
self.editor.insert_string(data, attrs_list);
|
||||
}
|
||||
|
||||
fn action(&mut self, action: Action) {
|
||||
self.editor.action(action);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use unicode_segmentation::UnicodeSegmentation;
|
|||
|
||||
use crate::{
|
||||
Action,
|
||||
AttrsList,
|
||||
Buffer,
|
||||
Color,
|
||||
Cursor,
|
||||
|
|
@ -83,6 +84,10 @@ impl<'a> Edit<'a> for ViEditor<'a> {
|
|||
self.editor.delete_selection()
|
||||
}
|
||||
|
||||
fn insert_string(&mut self, data: &str, attrs_list: Option<AttrsList>) {
|
||||
self.editor.insert_string(data, attrs_list);
|
||||
}
|
||||
|
||||
fn action(&mut self, action: Action) {
|
||||
let old_mode = self.mode;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue