mirror of https://github.com/lapce/lapce.git
Today I learn about the funky (..) discard syntax.
This commit is contained in:
parent
48fec1d862
commit
d83cb5d0d2
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue