From 275ef79f48321274af390d0f28ce154a5225abb7 Mon Sep 17 00:00:00 2001 From: Nawaf Date: Mon, 21 Aug 2023 15:17:29 -0400 Subject: [PATCH] cleanup code --- helix-term/src/ui/editor.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 394355abb..da18354c8 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -29,7 +29,7 @@ keyboard::{KeyCode, KeyModifiers}, Document, Editor, Theme, View, }; -use std::{cmp::Ordering, mem::take, num::NonZeroUsize, path::PathBuf, rc::Rc, sync::Arc}; +use std::{mem::take, num::NonZeroUsize, path::PathBuf, rc::Rc, sync::Arc}; use tui::{buffer::Buffer as Surface, text::Span}; @@ -569,17 +569,12 @@ pub fn render_bufferline(editor: &Editor, viewport: Rect, surface: &mut Surface) let mut to_trim = needed_width.saturating_sub(viewport.width as usize); for (idx, filename) in entries.iter().enumerate() { let mut text = filename.as_str(); - if to_trim > 0 { - match to_trim.cmp(&text.len()) { - Ordering::Less => { - text = &filename[to_trim..]; - to_trim = 0; - } - _ => { - to_trim -= text.len(); - continue; - } - } + if to_trim > 0 && to_trim < text.len() { + text = &filename[to_trim..]; + to_trim = 0; + } else if to_trim > 0 { + to_trim -= text.len(); + continue; } let style = if idx == current_doc_idx.unwrap() { bufferline_active