Fix clippy issues
This commit is contained in:
parent
2106b69c15
commit
80d89157e9
@ -182,12 +182,10 @@ fn cursor_rect(mode: &mode::Mode,
|
||||
} else {
|
||||
let cursor_width = if mode.is(&mode::NvimMode::Insert) {
|
||||
char_width / 5.0
|
||||
} else {
|
||||
if double_width {
|
||||
} else if double_width {
|
||||
char_width * 2.0
|
||||
} else {
|
||||
char_width
|
||||
}
|
||||
};
|
||||
|
||||
(line_y, cursor_width, line_height)
|
||||
|
@ -92,7 +92,7 @@ fn open_arg_impl<I>(args: I) -> Option<String>
|
||||
{
|
||||
args.skip(1)
|
||||
.last()
|
||||
.map(|a| if !a.starts_with("-") {
|
||||
.map(|a| if !a.starts_with('-') {
|
||||
Some(a.to_owned())
|
||||
} else {
|
||||
None
|
||||
|
40
src/nvim.rs
40
src/nvim.rs
@ -27,7 +27,7 @@ pub trait RedrawEvents {
|
||||
|
||||
fn on_redraw(&self, mode: &RepaintMode);
|
||||
|
||||
fn on_highlight_set(&mut self, attrs: &Vec<(Value, Value)>) -> RepaintMode;
|
||||
fn on_highlight_set(&mut self, attrs: &[(Value, Value)]) -> RepaintMode;
|
||||
|
||||
fn on_eol_clear(&mut self) -> RepaintMode;
|
||||
|
||||
@ -48,7 +48,7 @@ pub trait RedrawEvents {
|
||||
fn on_busy(&mut self, busy: bool) -> RepaintMode;
|
||||
|
||||
fn popupmenu_show(&mut self,
|
||||
menu: &Vec<Vec<&str>>,
|
||||
menu: &[Vec<&str>],
|
||||
selected: i64,
|
||||
row: u64,
|
||||
col: u64)
|
||||
@ -74,32 +74,32 @@ pub trait GuiApi {
|
||||
}
|
||||
|
||||
macro_rules! try_str {
|
||||
($exp:expr) => ($exp.as_str().ok_or("Can't convert argument to string".to_owned())?)
|
||||
($exp:expr) => ($exp.as_str().ok_or_else(|| "Can't convert argument to string".to_owned())?)
|
||||
}
|
||||
|
||||
macro_rules! try_int {
|
||||
($expr:expr) => ($expr.as_i64().ok_or("Can't convert argument to int".to_owned())?)
|
||||
($expr:expr) => ($expr.as_i64().ok_or_else(|| "Can't convert argument to int".to_owned())?)
|
||||
}
|
||||
|
||||
macro_rules! try_uint {
|
||||
($exp:expr) => ($exp.as_u64().ok_or("Can't convert argument to u64".to_owned())?)
|
||||
($exp:expr) => ($exp.as_u64().ok_or_else(|| "Can't convert argument to u64".to_owned())?)
|
||||
}
|
||||
|
||||
macro_rules! try_bool {
|
||||
($exp:expr) => ($exp.as_bool().ok_or("Can't convert argument to bool".to_owned())?)
|
||||
($exp:expr) => ($exp.as_bool().ok_or_else(|| "Can't convert argument to bool".to_owned())?)
|
||||
}
|
||||
|
||||
macro_rules! map_array {
|
||||
($arg:expr, $err:expr, |$item:ident| $exp:expr) => (
|
||||
$arg.as_array()
|
||||
.ok_or($err)
|
||||
.ok_or_else(|| $err)
|
||||
.and_then(|items| items.iter().map(|$item| {
|
||||
$exp
|
||||
}).collect::<Result<Vec<_>, _>>())
|
||||
);
|
||||
($arg:expr, $err:expr, |$item:ident| {$exp:expr}) => (
|
||||
$arg.as_array()
|
||||
.ok_or($err)
|
||||
.ok_or_else(|| $err)
|
||||
.and_then(|items| items.iter().map(|$item| {
|
||||
$exp
|
||||
}).collect::<Result<Vec<_>, _>>())
|
||||
@ -118,7 +118,7 @@ impl CursorShape {
|
||||
fn new(shape_code: &Value) -> Result<CursorShape, String> {
|
||||
let str_code = shape_code
|
||||
.as_str()
|
||||
.ok_or("Can't convert cursor shape to string".to_owned())?;
|
||||
.ok_or_else(|| "Can't convert cursor shape to string".to_owned())?;
|
||||
|
||||
Ok(match str_code {
|
||||
"block" => CursorShape::Block,
|
||||
@ -270,13 +270,13 @@ pub fn post_start_init(nvim: &mut Neovim,
|
||||
opts.set_popupmenu_external(false);
|
||||
opts.set_tabline_external(true);
|
||||
nvim.ui_attach(cols, rows, opts)
|
||||
.map_err(|e| NvimInitError::new_post_init(e))?;
|
||||
.map_err(NvimInitError::new_post_init)?;
|
||||
nvim.command("runtime! ginit.vim")
|
||||
.map_err(|e| NvimInitError::new_post_init(e))?;
|
||||
.map_err(NvimInitError::new_post_init)?;
|
||||
|
||||
if let Some(path) = open_path {
|
||||
nvim.command(&format!("e {}", path))
|
||||
.map_err(|e| NvimInitError::new_post_init(e))?;
|
||||
.map_err(NvimInitError::new_post_init)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -300,9 +300,9 @@ impl NvimHandler {
|
||||
for ev in ¶ms {
|
||||
if let Some(ev_args) = ev.as_array() {
|
||||
if let Some(ev_name) = ev_args[0].as_str() {
|
||||
for ref local_args in ev_args.iter().skip(1) {
|
||||
for local_args in ev_args.iter().skip(1) {
|
||||
let args = match *local_args {
|
||||
&Value::Array(ref ar) => ar.clone(),
|
||||
Value::Array(ref ar) => ar.clone(),
|
||||
_ => vec![],
|
||||
};
|
||||
let call_reapint_mode = call(ui, ev_name, &args)?;
|
||||
@ -321,7 +321,7 @@ impl NvimHandler {
|
||||
});
|
||||
}
|
||||
"Gui" => {
|
||||
if params.len() > 0 {
|
||||
if !params.is_empty() {
|
||||
if let Some(ev_name) = params[0].as_str().map(String::from) {
|
||||
let args = params.iter().skip(1).cloned().collect();
|
||||
self.safe_call(move |ui| {
|
||||
@ -390,7 +390,7 @@ fn call_gui_event(ui: &mut shell::State,
|
||||
|
||||
fn call(ui: &mut shell::State,
|
||||
method: &str,
|
||||
args: &Vec<Value>)
|
||||
args: &[Value])
|
||||
-> result::Result<RepaintMode, String> {
|
||||
let repaint_mode = match method {
|
||||
"cursor_goto" => ui.on_cursor_goto(try_uint!(args[0]), try_uint!(args[1])),
|
||||
@ -439,7 +439,7 @@ fn call(ui: &mut shell::State,
|
||||
"tabline_update" => {
|
||||
let tabs_out = map_array!(args[1], "Error get tabline list".to_owned(), |tab| {
|
||||
tab.as_map()
|
||||
.ok_or("Error get map for tab".to_owned())
|
||||
.ok_or_else(|| "Error get map for tab".to_owned())
|
||||
.and_then(|tab_map| tab_map.to_attrs_map())
|
||||
.map(|tab_attrs| {
|
||||
let name_attr = tab_attrs
|
||||
@ -460,7 +460,7 @@ fn call(ui: &mut shell::State,
|
||||
"Error get array key value for mode_info".to_owned(),
|
||||
|mi| {
|
||||
mi.as_map()
|
||||
.ok_or("Erro get map for mode_info".to_owned())
|
||||
.ok_or_else(|| "Erro get map for mode_info".to_owned())
|
||||
.and_then(|mi_map| ModeInfo::new(mi_map))
|
||||
})?;
|
||||
ui.mode_info_set(try_bool!(args[0]), mode_info)
|
||||
@ -480,7 +480,7 @@ pub trait ErrorReport {
|
||||
|
||||
impl<T> ErrorReport for result::Result<T, CallError> {
|
||||
fn report_err(&self, _: &mut NeovimApi) {
|
||||
if let &Err(ref err) = self {
|
||||
if let Err(ref err) = *self {
|
||||
println!("{}", err);
|
||||
//nvim.report_error(&err_msg).expect("Error report error :)");
|
||||
}
|
||||
@ -509,7 +509,7 @@ impl RepaintMode {
|
||||
}
|
||||
(RepaintMode::AreaList(mut target), RepaintMode::AreaList(source)) => {
|
||||
for s in &source.list {
|
||||
target.join(&s);
|
||||
target.join(s);
|
||||
}
|
||||
RepaintMode::AreaList(target)
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ impl State {
|
||||
|
||||
fn before_show(&mut self,
|
||||
shell: &shell::State,
|
||||
menu_items: &Vec<Vec<&str>>,
|
||||
menu_items: &[Vec<&str>],
|
||||
selected: i64) {
|
||||
if self.nvim.is_none() {
|
||||
self.nvim = Some(shell.nvim_clone());
|
||||
@ -45,7 +45,7 @@ impl State {
|
||||
self.select(selected);
|
||||
}
|
||||
|
||||
fn update_tree(&self, menu: &Vec<Vec<&str>>, shell: &shell::State) {
|
||||
fn update_tree(&self, menu: &[Vec<&str>], shell: &shell::State) {
|
||||
if menu.is_empty() {
|
||||
return;
|
||||
}
|
||||
@ -55,7 +55,7 @@ impl State {
|
||||
self.renderer.set_property_foreground_rgba(Some(&shell.get_foreground().into()));
|
||||
self.renderer.set_property_background_rgba(Some(&shell.get_background().into()));
|
||||
|
||||
let col_count = menu.get(0).unwrap().len();
|
||||
let col_count = menu[0].len();
|
||||
let columns = self.tree.get_columns();
|
||||
|
||||
if columns.len() != col_count {
|
||||
@ -166,7 +166,7 @@ impl PopupMenu {
|
||||
|
||||
pub fn show(&mut self,
|
||||
shell: &shell::State,
|
||||
menu_items: &Vec<Vec<&str>>,
|
||||
menu_items: &[Vec<&str>],
|
||||
selected: i64,
|
||||
x: i32,
|
||||
y: i32,
|
||||
|
@ -21,12 +21,12 @@ const CURRENT_DIR_PIXBUF: &str = "folder";
|
||||
const PLAIN_FILE_PIXBUF: &str = "text-x-generic";
|
||||
|
||||
enum ProjectViewColumns {
|
||||
NameColumn,
|
||||
PathColumn,
|
||||
UriColumn,
|
||||
PixbufColumn,
|
||||
ProjectColumn,
|
||||
ProjectStoredColumn,
|
||||
Name,
|
||||
Path,
|
||||
Uri,
|
||||
Pixbuf,
|
||||
Project,
|
||||
ProjectStored,
|
||||
}
|
||||
|
||||
const COLUMN_COUNT: usize = 6;
|
||||
@ -36,12 +36,12 @@ const COLUMN_TYPES: [Type; COLUMN_COUNT] = [Type::String,
|
||||
Type::String,
|
||||
Type::Bool,
|
||||
Type::Bool];
|
||||
const COLUMN_IDS: [u32; COLUMN_COUNT] = [ProjectViewColumns::NameColumn as u32,
|
||||
ProjectViewColumns::PathColumn as u32,
|
||||
ProjectViewColumns::UriColumn as u32,
|
||||
ProjectViewColumns::PixbufColumn as u32,
|
||||
ProjectViewColumns::ProjectColumn as u32,
|
||||
ProjectViewColumns::ProjectStoredColumn as u32];
|
||||
const COLUMN_IDS: [u32; COLUMN_COUNT] = [ProjectViewColumns::Name as u32,
|
||||
ProjectViewColumns::Path as u32,
|
||||
ProjectViewColumns::Uri as u32,
|
||||
ProjectViewColumns::Pixbuf as u32,
|
||||
ProjectViewColumns::Project as u32,
|
||||
ProjectViewColumns::ProjectStored as u32];
|
||||
|
||||
pub struct Projects {
|
||||
shell: Rc<RefCell<Shell>>,
|
||||
@ -161,12 +161,12 @@ impl Projects {
|
||||
let list_store = self.get_list_store();
|
||||
if let Some(iter) = list_store.get_iter(path) {
|
||||
let value: bool = list_store
|
||||
.get_value(&iter, ProjectViewColumns::ProjectStoredColumn as i32)
|
||||
.get_value(&iter, ProjectViewColumns::ProjectStored as i32)
|
||||
.get()
|
||||
.unwrap();
|
||||
|
||||
list_store.set_value(&iter,
|
||||
ProjectViewColumns::ProjectStoredColumn as u32,
|
||||
ProjectViewColumns::ProjectStored as u32,
|
||||
&ToValue::to_value(&!value));
|
||||
|
||||
let pixbuf = if value {
|
||||
@ -176,10 +176,10 @@ impl Projects {
|
||||
};
|
||||
|
||||
list_store.set_value(&iter,
|
||||
ProjectViewColumns::PixbufColumn as u32,
|
||||
ProjectViewColumns::Pixbuf as u32,
|
||||
&ToValue::to_value(pixbuf));
|
||||
|
||||
let uri_value = list_store.get_value(&iter, ProjectViewColumns::UriColumn as i32);
|
||||
let uri_value = list_store.get_value(&iter, ProjectViewColumns::Uri as i32);
|
||||
let uri: String = uri_value.get().unwrap();
|
||||
|
||||
let mut store = self.store.as_mut().unwrap();
|
||||
@ -194,8 +194,8 @@ impl Projects {
|
||||
|
||||
|
||||
fn open_uri(&self, model: &TreeModel, iter: &TreeIter) {
|
||||
let uri: String = model.get_value(&iter, ProjectViewColumns::UriColumn as i32).get().unwrap();
|
||||
let project: bool = model.get_value(&iter, ProjectViewColumns::ProjectColumn as i32).get().unwrap();
|
||||
let uri: String = model.get_value(iter, ProjectViewColumns::Uri as i32).get().unwrap();
|
||||
let project: bool = model.get_value(iter, ProjectViewColumns::Project as i32).get().unwrap();
|
||||
|
||||
let shell = self.shell.borrow();
|
||||
if project {
|
||||
@ -226,16 +226,13 @@ impl Projects {
|
||||
const CANCEL_ID: i32 = 1;
|
||||
|
||||
dlg.add_buttons(&[("_Open", OPEN_ID), ("_Cancel", CANCEL_ID)]);
|
||||
match dlg.run() {
|
||||
OPEN_ID => {
|
||||
if dlg.run() == OPEN_ID {
|
||||
if let Some(filename) = dlg.get_filename() {
|
||||
if let Some(filename) = filename.to_str() {
|
||||
self.shell.borrow().open_file(filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
dlg.destroy();
|
||||
}
|
||||
|
||||
@ -271,7 +268,7 @@ impl Projects {
|
||||
|
||||
image_column.add_attribute(&icon_renderer,
|
||||
"icon-name",
|
||||
ProjectViewColumns::PixbufColumn as i32);
|
||||
ProjectViewColumns::Pixbuf as i32);
|
||||
|
||||
self.tree.append_column(&image_column);
|
||||
|
||||
@ -287,10 +284,10 @@ impl Projects {
|
||||
|
||||
text_column.add_attribute(&self.name_renderer,
|
||||
"markup",
|
||||
ProjectViewColumns::NameColumn as i32);
|
||||
ProjectViewColumns::Name as i32);
|
||||
text_column.add_attribute(&self.path_renderer,
|
||||
"markup",
|
||||
ProjectViewColumns::PathColumn as i32);
|
||||
ProjectViewColumns::Path as i32);
|
||||
|
||||
let area = text_column
|
||||
.get_area()
|
||||
@ -309,10 +306,10 @@ impl Projects {
|
||||
toggle_column.pack_start(&self.toggle_renderer, true);
|
||||
toggle_column.add_attribute(&self.toggle_renderer,
|
||||
"visible",
|
||||
ProjectViewColumns::ProjectColumn as i32);
|
||||
ProjectViewColumns::Project as i32);
|
||||
toggle_column.add_attribute(&self.toggle_renderer,
|
||||
"active",
|
||||
ProjectViewColumns::ProjectStoredColumn as i32);
|
||||
ProjectViewColumns::ProjectStored as i32);
|
||||
|
||||
self.tree.append_column(&toggle_column);
|
||||
}
|
||||
@ -384,7 +381,7 @@ impl EntryStore {
|
||||
pub fn find_mut(&mut self, uri: &str) -> Option<&mut Entry> {
|
||||
self.entries
|
||||
.iter_mut()
|
||||
.find(|e| e.project == true && e.uri == uri)
|
||||
.find(|e| e.project && e.uri == uri)
|
||||
}
|
||||
|
||||
pub fn load(nvim: &mut Neovim) -> EntryStore {
|
||||
@ -399,7 +396,7 @@ impl EntryStore {
|
||||
if let Some(pwd) = pwd.as_str() {
|
||||
if entries
|
||||
.iter()
|
||||
.find(|e| e.project == true && e.uri == pwd)
|
||||
.find(|e| e.project && e.uri == pwd)
|
||||
.is_none() {
|
||||
entries.insert(0, Entry::new_current_project(pwd));
|
||||
}
|
||||
@ -467,7 +464,7 @@ impl Entry {
|
||||
uri: uri.to_owned(),
|
||||
path: path.parent()
|
||||
.map(|s| format!("<small>{}</small>", encode_minimal(&s.to_string_lossy())))
|
||||
.unwrap_or("".to_owned()),
|
||||
.unwrap_or_else(|| "".to_owned()),
|
||||
file_name: format!("<big>{}</big>", encode_minimal(name)),
|
||||
name: name.to_owned(),
|
||||
pixbuf: BOOKMARKED_PIXBUF,
|
||||
@ -480,13 +477,13 @@ impl Entry {
|
||||
let path = Path::new(uri);
|
||||
let name = path.file_name()
|
||||
.map(|f| f.to_string_lossy().as_ref().to_owned())
|
||||
.unwrap_or(path.to_string_lossy().as_ref().to_owned());
|
||||
.unwrap_or_else(|| path.to_string_lossy().as_ref().to_owned());
|
||||
|
||||
Entry {
|
||||
uri: uri.to_owned(),
|
||||
path: path.parent()
|
||||
.map(|s| format!("<small>{}</small>", encode_minimal(&s.to_string_lossy())))
|
||||
.unwrap_or("".to_owned()),
|
||||
.unwrap_or_else(|| "".to_owned()),
|
||||
file_name: format!("<big>{}</big>", encode_minimal(&name)),
|
||||
name,
|
||||
pixbuf: CURRENT_DIR_PIXBUF,
|
||||
@ -499,7 +496,7 @@ impl Entry {
|
||||
let path = Path::new(uri);
|
||||
let name = path.file_name()
|
||||
.map(|f| f.to_string_lossy().as_ref().to_owned())
|
||||
.unwrap_or("<empty>".to_owned());
|
||||
.unwrap_or_else(|| "<empty>".to_owned());
|
||||
|
||||
Entry {
|
||||
uri: uri.to_owned(),
|
||||
@ -508,7 +505,7 @@ impl Entry {
|
||||
format!("<small>{}</small>",
|
||||
encode_minimal(&s.to_string_lossy()))
|
||||
})
|
||||
.unwrap_or("".to_owned()),
|
||||
.unwrap_or_else(|| "".to_owned()),
|
||||
file_name: format!("<big>{}</big>", encode_minimal(&name)),
|
||||
name,
|
||||
pixbuf: PLAIN_FILE_PIXBUF,
|
||||
|
23
src/shell.rs
23
src/shell.rs
@ -198,7 +198,7 @@ impl State {
|
||||
}
|
||||
}
|
||||
|
||||
fn queue_draw_area<M: AsRef<ModelRect>>(&self, rect_list: &Vec<M>) {
|
||||
fn queue_draw_area<M: AsRef<ModelRect>>(&self, rect_list: &[M]) {
|
||||
match (&self.line_height, &self.char_width) {
|
||||
(&Some(line_height), &Some(char_width)) => {
|
||||
for rect in rect_list {
|
||||
@ -964,11 +964,11 @@ impl RedrawEvents for State {
|
||||
}
|
||||
|
||||
fn on_redraw(&self, mode: &RepaintMode) {
|
||||
match mode {
|
||||
&RepaintMode::All => self.drawing_area.queue_draw(),
|
||||
&RepaintMode::Area(ref rect) => self.queue_draw_area(&vec![rect]),
|
||||
&RepaintMode::AreaList(ref list) => self.queue_draw_area(&list.list),
|
||||
&RepaintMode::Nothing => (),
|
||||
match *mode {
|
||||
RepaintMode::All => self.drawing_area.queue_draw(),
|
||||
RepaintMode::Area(ref rect) => self.queue_draw_area(&[rect]),
|
||||
RepaintMode::AreaList(ref list) => self.queue_draw_area(&list.list),
|
||||
RepaintMode::Nothing => (),
|
||||
}
|
||||
}
|
||||
|
||||
@ -981,7 +981,7 @@ impl RedrawEvents for State {
|
||||
RepaintMode::Area(self.model.scroll(count))
|
||||
}
|
||||
|
||||
fn on_highlight_set(&mut self, attrs: &Vec<(Value, Value)>) -> RepaintMode {
|
||||
fn on_highlight_set(&mut self, attrs: &[(Value, Value)]) -> RepaintMode {
|
||||
let mut model_attrs = Attrs::new();
|
||||
|
||||
for &(ref key_val, ref val) in attrs {
|
||||
@ -1065,22 +1065,19 @@ impl RedrawEvents for State {
|
||||
}
|
||||
|
||||
fn popupmenu_show(&mut self,
|
||||
menu: &Vec<Vec<&str>>,
|
||||
menu: &[Vec<&str>],
|
||||
selected: i64,
|
||||
row: u64,
|
||||
col: u64)
|
||||
-> RepaintMode {
|
||||
match (&self.line_height, &self.char_width) {
|
||||
(&Some(line_height), &Some(char_width)) => {
|
||||
if let (&Some(line_height), &Some(char_width)) = (&self.line_height, &self.char_width) {
|
||||
let point = ModelRect::point(col as usize, row as usize);
|
||||
let (x, y, width, height) = point.to_area(line_height, char_width);
|
||||
|
||||
self.popup_menu
|
||||
.borrow_mut()
|
||||
.show(&self, menu, selected, x, y, width, height);
|
||||
.show(self, menu, selected, x, y, width, height);
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
|
||||
RepaintMode::Nothing
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ pub fn can_close_window(comps: &UiMutex<Components>, shell: &RefCell<Shell>) ->
|
||||
|
||||
fn show_not_saved_dlg(comps: &UiMutex<Components>,
|
||||
shell: &Shell,
|
||||
changed_bufs: &Vec<String>)
|
||||
changed_bufs: &[String])
|
||||
-> bool {
|
||||
let mut changed_files = changed_bufs
|
||||
.iter()
|
||||
@ -62,8 +62,7 @@ fn show_not_saved_dlg(comps: &UiMutex<Components>,
|
||||
}
|
||||
}
|
||||
CLOSE_WITHOUT_SAVE => true,
|
||||
CANCEL_ID => false,
|
||||
_ => false,
|
||||
CANCEL_ID | _ => false,
|
||||
};
|
||||
|
||||
dlg.destroy();
|
||||
|
@ -32,7 +32,7 @@ impl State {
|
||||
let target = &self.data[idx as usize];
|
||||
if Some(target) != self.selected.as_ref() {
|
||||
let mut nvim = self.nvim.as_ref().unwrap().borrow_mut();
|
||||
nvim.set_current_tabpage(&target).report_err(&mut **nvim);
|
||||
nvim.set_current_tabpage(target).report_err(&mut **nvim);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -69,7 +69,7 @@ impl Tabline {
|
||||
fn update_state(&self,
|
||||
nvim: &Rc<RefCell<nvim::NeovimClient>>,
|
||||
selected: &Tabpage,
|
||||
tabs: &Vec<(Tabpage, Option<String>)>) {
|
||||
tabs: &[(Tabpage, Option<String>)]) {
|
||||
let mut state = self.state.borrow_mut();
|
||||
|
||||
if state.nvim.is_none() {
|
||||
@ -84,7 +84,7 @@ impl Tabline {
|
||||
pub fn update_tabs(&self,
|
||||
nvim: &Rc<RefCell<nvim::NeovimClient>>,
|
||||
selected: &Tabpage,
|
||||
tabs: &Vec<(Tabpage, Option<String>)>) {
|
||||
tabs: &[(Tabpage, Option<String>)]) {
|
||||
if tabs.len() <= 1 {
|
||||
self.tabs.hide();
|
||||
return;
|
||||
@ -113,7 +113,7 @@ impl Tabline {
|
||||
for (idx, tab) in tabs.iter().enumerate() {
|
||||
let tab_child = self.tabs.get_nth_page(Some(idx as u32));
|
||||
self.tabs
|
||||
.set_tab_label_text(&tab_child.unwrap(), &tab.1.as_ref().unwrap_or(&"??".to_owned()));
|
||||
.set_tab_label_text(&tab_child.unwrap(), tab.1.as_ref().unwrap_or(&"??".to_owned()));
|
||||
|
||||
if *selected == tab.0 {
|
||||
self.tabs.set_current_page(Some(idx as u32));
|
||||
|
@ -172,8 +172,8 @@ impl UiModel {
|
||||
let mut cell = &mut self.model[self.cur_row][self.cur_col];
|
||||
|
||||
cell.ch = text.chars().last().unwrap_or(' ');
|
||||
cell.attrs = attrs.map(Attrs::clone).unwrap_or_else(|| Attrs::new());
|
||||
cell.attrs.double_width = text.len() == 0;
|
||||
cell.attrs = attrs.map(Attrs::clone).unwrap_or_else(Attrs::new);
|
||||
cell.attrs.double_width = text.is_empty();
|
||||
self.cur_col += 1;
|
||||
if self.cur_col >= self.columns {
|
||||
self.cur_col -= 1;
|
||||
@ -274,7 +274,7 @@ impl ModelRectVec {
|
||||
|
||||
pub fn join(&mut self, other: &ModelRect) {
|
||||
match self.find_neighbor(other) {
|
||||
Some(i) => self.list.get_mut(i).unwrap().join(other),
|
||||
Some(i) => self.list[i].join(other),
|
||||
None => self.list.push(other.clone()),
|
||||
}
|
||||
}
|
||||
@ -379,17 +379,7 @@ impl ModelRect {
|
||||
x2: f64,
|
||||
y2: f64)
|
||||
-> ModelRect {
|
||||
let x1 = if x1 > 0.0 {
|
||||
x1 // - 1.0
|
||||
} else {
|
||||
x1
|
||||
};
|
||||
let x2 = if x2 > 0.0 { x2 - 1.0 } else { x2 };
|
||||
let y1 = if y1 > 0.0 {
|
||||
y1 // - 1.0
|
||||
} else {
|
||||
y1
|
||||
};
|
||||
let y2 = if y2 > 0.0 { y2 - 1.0 } else { y2 };
|
||||
let left = (x1 / char_width) as usize;
|
||||
let right = (x2 / char_width) as usize;
|
||||
@ -435,11 +425,11 @@ impl<'a> Iterator for ClipRowIterator<'a> {
|
||||
|
||||
pub struct ClipLine<'a> {
|
||||
rect: &'a ModelRect,
|
||||
line: &'a Vec<Cell>,
|
||||
line: &'a [Cell],
|
||||
}
|
||||
|
||||
impl<'a> ClipLine<'a> {
|
||||
pub fn new(model: &'a Vec<Cell>, rect: &'a ModelRect) -> ClipLine<'a> {
|
||||
pub fn new(model: &'a [Cell], rect: &'a ModelRect) -> ClipLine<'a> {
|
||||
ClipLine {
|
||||
line: model,
|
||||
rect: rect,
|
||||
@ -469,7 +459,7 @@ pub struct ClipColIterator<'a> {
|
||||
}
|
||||
|
||||
impl<'a> ClipColIterator<'a> {
|
||||
pub fn new(model: &'a Vec<Cell>, rect: &'a ModelRect) -> ClipColIterator<'a> {
|
||||
pub fn new(model: &'a [Cell], rect: &'a ModelRect) -> ClipColIterator<'a> {
|
||||
ClipColIterator {
|
||||
rect: rect,
|
||||
pos: 0,
|
||||
|
@ -11,7 +11,7 @@ impl ValueMapExt for Vec<(Value, Value)> {
|
||||
.map(|p| {
|
||||
p.0
|
||||
.as_str()
|
||||
.ok_or("Can't convert map key to string".to_owned())
|
||||
.ok_or_else(|| "Can't convert map key to string".to_owned())
|
||||
.map(|key| (key, p.1.clone()))
|
||||
})
|
||||
.collect::<Result<HashMap<&str, Value>, String>>()
|
||||
|
Loading…
Reference in New Issue
Block a user