From d83cb5d0d2c28d932746ea08b83767a545604f2a Mon Sep 17 00:00:00 2001 From: Philip Daniels Date: Tue, 24 May 2022 22:15:29 +0100 Subject: [PATCH] Today I learn about the funky (..) discard syntax. --- lapce-data/src/data.rs | 8 ++++---- lapce-data/src/document.rs | 14 +++++++------- lapce-data/src/editor.rs | 4 ++-- lapce-ui/src/editor.rs | 2 +- lapce-ui/src/editor/header.rs | 2 +- lapce-ui/src/editor/tab_header_content.rs | 2 +- lapce-ui/src/editor/view.rs | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lapce-data/src/data.rs b/lapce-data/src/data.rs index c0d5b783..5304d11f 100644 --- a/lapce-data/src/data.rs +++ b/lapce-data/src/data.rs @@ -823,7 +823,7 @@ pub fn completion_origin( *editor.window_origin.borrow() - self.window_origin.borrow().to_vec2() } - BufferContent::File(_) | BufferContent::Scratch(_, _) => { + BufferContent::File(_) | BufferContent::Scratch(..) => { let doc = self.main_split.editor_doc(editor.view_id); let offset = self.completion.offset; let (line, col) = doc.buffer().offset_to_line_col(offset); @@ -879,7 +879,7 @@ pub fn hover_origin( *editor.window_origin.borrow() - self.window_origin.borrow().to_vec2() } - BufferContent::File(_) | BufferContent::Scratch(_, _) => { + BufferContent::File(_) | BufferContent::Scratch(..) => { let doc = self.main_split.editor_doc(editor.view_id); let offset = self.hover.offset; let (line, col) = doc.buffer().offset_to_line_col(offset); @@ -2306,7 +2306,7 @@ pub fn go_to_location( BufferContent::File(path) => path != &location.path, BufferContent::Local(_) => true, BufferContent::Value(_) => true, - BufferContent::Scratch(_, _) => true, + BufferContent::Scratch(..) => true, }; if new_buffer { self.db.save_doc_position(&self.workspace, &doc); @@ -2709,7 +2709,7 @@ pub fn editor_close( force: bool, ) { let editor = self.editors.get(&view_id).unwrap(); - if let BufferContent::File(_) | BufferContent::Scratch(_, _) = + if let BufferContent::File(_) | BufferContent::Scratch(..) = &editor.content { let doc = self.editor_doc(view_id); diff --git a/lapce-data/src/document.rs b/lapce-data/src/document.rs index 6e71b2ab..4d9b83f6 100644 --- a/lapce-data/src/document.rs +++ b/lapce-data/src/document.rs @@ -120,7 +120,7 @@ pub fn is_special(&self) -> bool { LocalBufferKind::Empty => false, }, BufferContent::Value(_) => true, - BufferContent::Scratch(_, _) => false, + BufferContent::Scratch(..) => false, } } @@ -136,7 +136,7 @@ pub fn is_input(&self) -> bool { LocalBufferKind::Empty | LocalBufferKind::SourceControl => false, }, BufferContent::Value(_) => true, - BufferContent::Scratch(_, _) => false, + BufferContent::Scratch(..) => false, } } @@ -144,7 +144,7 @@ pub fn is_search(&self) -> bool { match &self { BufferContent::File(_) => false, BufferContent::Value(_) => false, - BufferContent::Scratch(_, _) => false, + BufferContent::Scratch(..) => false, BufferContent::Local(local) => matches!(local, LocalBufferKind::Search), } } @@ -154,7 +154,7 @@ pub fn is_settings(&self) -> bool { BufferContent::File(_) => false, BufferContent::Value(_) => true, BufferContent::Local(_) => false, - BufferContent::Scratch(_, _) => false, + BufferContent::Scratch(..) => false, } } @@ -202,7 +202,7 @@ pub fn new( BufferContent::File(path) => Syntax::init(path), BufferContent::Local(_) => None, BufferContent::Value(_) => None, - BufferContent::Scratch(_, _) => None, + BufferContent::Scratch(..) => None, }; let id = match &content { BufferContent::Scratch(id, _) => *id, @@ -245,7 +245,7 @@ pub fn set_content(&mut self, content: BufferContent) { BufferContent::File(path) => Syntax::init(path), BufferContent::Local(_) => None, BufferContent::Value(_) => None, - BufferContent::Scratch(_, _) => None, + BufferContent::Scratch(..) => None, }; self.on_update(None); } @@ -473,7 +473,7 @@ fn on_update(&mut self, delta: Option<&RopeDelta>) { fn notify_special(&self) { match &self.content { BufferContent::File(_) => {} - BufferContent::Scratch(_, _) => {} + BufferContent::Scratch(..) => {} BufferContent::Local(local) => { let s = self.buffer.text().to_string(); match local { diff --git a/lapce-data/src/editor.rs b/lapce-data/src/editor.rs index b2929468..489c00b5 100644 --- a/lapce-data/src/editor.rs +++ b/lapce-data/src/editor.rs @@ -1175,7 +1175,7 @@ fn save(&mut self, ctx: &mut EventCtx, exit: bool) { Target::Auto, ); }); - } else if let BufferContent::Scratch(_, _) = self.doc.content() { + } else if let BufferContent::Scratch(..) = self.doc.content() { let content = self.doc.content().clone(); let view_id = self.editor.view_id; self.main_split.current_save_as = @@ -1945,7 +1945,7 @@ fn check_condition(&self, condition: &str) -> bool { "input_focus" => self.editor.content.is_input(), "editor_focus" => match self.editor.content { BufferContent::File(_) => true, - BufferContent::Scratch(_, _) => true, + BufferContent::Scratch(..) => true, BufferContent::Local(_) => false, BufferContent::Value(_) => false, }, diff --git a/lapce-ui/src/editor.rs b/lapce-ui/src/editor.rs index b5ead8ff..e0a5942e 100644 --- a/lapce-ui/src/editor.rs +++ b/lapce-ui/src/editor.rs @@ -285,7 +285,7 @@ pub fn get_size( let width = data.config.editor_char_width(text); match &data.editor.content { BufferContent::File(_) - | BufferContent::Scratch(_, _) + | BufferContent::Scratch(..) | BufferContent::Local(LocalBufferKind::Empty) => { if data.editor.code_lens { if let Some(syntax) = data.doc.syntax() { diff --git a/lapce-ui/src/editor/header.rs b/lapce-ui/src/editor/header.rs index 33e5ff30..34792f5a 100644 --- a/lapce-ui/src/editor/header.rs +++ b/lapce-ui/src/editor/header.rs @@ -135,7 +135,7 @@ pub fn paint_buffer( clip_rect.x1 = icon.rect.x0; } } - if let BufferContent::File(_) | BufferContent::Scratch(_, _) = + if let BufferContent::File(_) | BufferContent::Scratch(..) = data.doc.content() { let mut path = match data.doc.content() { diff --git a/lapce-ui/src/editor/tab_header_content.rs b/lapce-ui/src/editor/tab_header_content.rs index 6a83d06d..1a43aeb1 100644 --- a/lapce-ui/src/editor/tab_header_content.rs +++ b/lapce-ui/src/editor/tab_header_content.rs @@ -364,7 +364,7 @@ fn layout( text = s.to_string(); } } - } else if let BufferContent::Scratch(_, _) = &editor.content { + } else if let BufferContent::Scratch(..) = &editor.content { text = editor.content.file_name().to_string(); } } diff --git a/lapce-ui/src/editor/view.rs b/lapce-ui/src/editor/view.rs index d8073edb..386461b3 100644 --- a/lapce-ui/src/editor/view.rs +++ b/lapce-ui/src/editor/view.rs @@ -120,7 +120,7 @@ pub fn request_focus( )); } match &editor.content { - BufferContent::File(_) | BufferContent::Scratch(_, _) => { + BufferContent::File(_) | BufferContent::Scratch(..) => { data.focus_area = FocusArea::Editor; data.main_split.active = Arc::new(Some(self.view_id)); data.main_split.active_tab = Arc::new(editor.tab_id);