code actions menu position

This commit is contained in:
Dongdong Zhou 2022-05-23 14:42:56 +01:00
parent c19f2bf222
commit ca66800f51
22 changed files with 290 additions and 109 deletions

6
Cargo.lock generated
View File

@ -771,7 +771,7 @@ dependencies = [
[[package]]
name = "druid"
version = "0.7.0"
source = "git+https://github.com/lapce/druid?branch=shell_opengl#f456d1e98274c9b809129cae477d3e4d5a30713e"
source = "git+https://github.com/lapce/druid?branch=shell_opengl#170b0870c7cd0782ee85291ead3a1ddf2a39e3ff"
dependencies = [
"console_error_panic_hook",
"druid-derive",
@ -794,7 +794,7 @@ dependencies = [
[[package]]
name = "druid-derive"
version = "0.4.0"
source = "git+https://github.com/lapce/druid?branch=shell_opengl#f456d1e98274c9b809129cae477d3e4d5a30713e"
source = "git+https://github.com/lapce/druid?branch=shell_opengl#170b0870c7cd0782ee85291ead3a1ddf2a39e3ff"
dependencies = [
"proc-macro2",
"quote",
@ -804,7 +804,7 @@ dependencies = [
[[package]]
name = "druid-shell"
version = "0.7.0"
source = "git+https://github.com/lapce/druid?branch=shell_opengl#f456d1e98274c9b809129cae477d3e4d5a30713e"
source = "git+https://github.com/lapce/druid?branch=shell_opengl#170b0870c7cd0782ee85291ead3a1ddf2a39e3ff"
dependencies = [
"anyhow",
"bitflags",

View File

@ -406,7 +406,7 @@ pub enum LapceUICommand {
UpdateCodeActions(PathBuf, u64, usize, CodeActionResponse),
CancelPalette,
RunCodeAction(CodeActionOrCommand),
ShowCodeActions,
ShowCodeActions(Option<Point>),
CancelCodeActions,
Hide,
ResignFocus,

View File

@ -2031,7 +2031,7 @@ fn get_editor_or_new(
let editor_tab =
Arc::make_mut(self.editor_tabs.get_mut(&active).unwrap());
match &editor_tab.children[editor_tab.active] {
EditorTabChild::Editor(id, _) => {
EditorTabChild::Editor(id, _, _) => {
if config.editor.show_tab {
if path.is_some() || scratch {
let mut editor_size = Size::ZERO;
@ -2039,7 +2039,7 @@ fn get_editor_or_new(
editor_tab.children.iter().enumerate()
{
match child {
EditorTabChild::Editor(id, _) => {
EditorTabChild::Editor(id, _, _) => {
let editor =
self.editors.get(id).unwrap();
let current_size =
@ -2073,6 +2073,7 @@ fn get_editor_or_new(
}
let new_editor = Arc::new(LapceEditorData::new(
None,
None,
Some(editor_tab.widget_id),
BufferContent::Local(LocalBufferKind::Empty),
@ -2083,6 +2084,7 @@ fn get_editor_or_new(
editor_tab.active + 1,
EditorTabChild::Editor(
new_editor.view_id,
new_editor.editor_id,
new_editor.find_view_id,
),
);
@ -2092,6 +2094,7 @@ fn get_editor_or_new(
editor_tab.active + 1,
EditorTabChild::Editor(
new_editor.view_id,
new_editor.editor_id,
new_editor.find_view_id,
),
),
@ -2132,6 +2135,7 @@ fn get_editor_or_new(
};
let editor = Arc::new(LapceEditorData::new(
None,
None,
Some(editor_tab.widget_id),
BufferContent::Local(LocalBufferKind::Empty),
@ -2140,6 +2144,7 @@ fn get_editor_or_new(
editor_tab.children.push(EditorTabChild::Editor(
editor.view_id,
editor.editor_id,
editor.find_view_id,
));
@ -2152,6 +2157,7 @@ fn get_editor_or_new(
0,
EditorTabChild::Editor(
editor.view_id,
editor.editor_id,
editor.find_view_id,
),
),
@ -2419,6 +2425,7 @@ pub fn new(
let editor = LapceEditorData::new(
Some(palette_preview_editor),
None,
None,
BufferContent::Local(LocalBufferKind::Empty),
config,
);
@ -2480,9 +2487,10 @@ pub fn new(
}
pub fn insert_editor(&mut self, editor: Arc<LapceEditorData>, config: &Config) {
if let Some(find_view_id) = editor.find_view_id {
if let Some((find_view_id, find_editor_id)) = editor.find_view_id {
let mut find_editor = LapceEditorData::new(
Some(find_view_id),
Some(find_editor_id),
None,
BufferContent::Local(LocalBufferKind::Search),
config,
@ -2512,6 +2520,7 @@ pub fn add_editor(
let editor = LapceEditorData::new(
Some(view_id),
None,
split_id,
BufferContent::Local(buffer_kind),
config,
@ -2901,6 +2910,7 @@ pub fn split_editor(
active: 0,
children: vec![EditorTabChild::Editor(
new_editor.view_id,
new_editor.editor_id,
new_editor.find_view_id,
)],
layout_rect: Rc::new(RefCell::new(Rect::ZERO)),
@ -2946,19 +2956,19 @@ pub enum InlineFindDirection {
#[derive(Clone, Debug, PartialEq)]
pub enum EditorTabChild {
Editor(WidgetId, Option<WidgetId>),
Editor(WidgetId, WidgetId, Option<(WidgetId, WidgetId)>),
}
impl EditorTabChild {
pub fn widget_id(&self) -> WidgetId {
match &self {
EditorTabChild::Editor(widget_id, _) => *widget_id,
EditorTabChild::Editor(widget_id, _, _) => *widget_id,
}
}
pub fn child_info(&self, data: &LapceTabData) -> EditorTabChildInfo {
match &self {
EditorTabChild::Editor(view_id, _) => {
EditorTabChild::Editor(view_id, _, _) => {
let editor_data = data.main_split.editors.get(view_id).unwrap();
EditorTabChildInfo::Editor(editor_data.editor_info(data))
}
@ -2967,7 +2977,7 @@ pub fn child_info(&self, data: &LapceTabData) -> EditorTabChildInfo {
pub fn set_editor_tab(&self, data: &mut LapceTabData, editor_tab_id: WidgetId) {
match &self {
EditorTabChild::Editor(view_id, _) => {
EditorTabChild::Editor(view_id, _, _) => {
let editor_data = data.main_split.editors.get_mut(view_id).unwrap();
let editor_data = Arc::make_mut(editor_data);
editor_data.tab_id = Some(editor_tab_id);
@ -3019,8 +3029,9 @@ pub enum EditorView {
pub struct LapceEditorData {
pub tab_id: Option<WidgetId>,
pub view_id: WidgetId,
pub editor_id: WidgetId,
pub parent_view_id: Option<WidgetId>,
pub find_view_id: Option<WidgetId>,
pub find_view_id: Option<(WidgetId, WidgetId)>,
pub content: BufferContent,
pub view: EditorView,
pub compare: Option<String>,
@ -3041,6 +3052,7 @@ pub struct LapceEditorData {
impl LapceEditorData {
pub fn new(
view_id: Option<WidgetId>,
editor_id: Option<WidgetId>,
tab_id: Option<WidgetId>,
content: BufferContent,
config: &Config,
@ -3048,12 +3060,13 @@ pub fn new(
Self {
tab_id,
view_id: view_id.unwrap_or_else(WidgetId::next),
editor_id: editor_id.unwrap_or_else(WidgetId::next),
view: EditorView::Normal,
parent_view_id: None,
find_view_id: if content.is_special() {
None
} else {
Some(WidgetId::next())
Some((WidgetId::next(), WidgetId::next()))
},
scroll_offset: Vec2::ZERO,
new_cursor: if content.is_input() {
@ -3081,7 +3094,9 @@ pub fn new(
pub fn copy(&self, new_view_id: WidgetId) -> LapceEditorData {
let mut new_editor = self.clone();
new_editor.view_id = new_view_id;
new_editor.find_view_id = new_editor.find_view_id.map(|_| WidgetId::next());
new_editor.find_view_id = new_editor
.find_view_id
.map(|_| (WidgetId::next(), WidgetId::next()));
new_editor.size = Rc::new(RefCell::new(Size::ZERO));
new_editor.window_origin = Rc::new(RefCell::new(Point::ZERO));
new_editor

View File

@ -157,7 +157,11 @@ pub fn to_data(
config,
event_sink,
);
EditorTabChild::Editor(editor_data.view_id, editor_data.find_view_id)
EditorTabChild::Editor(
editor_data.view_id,
editor_data.editor_id,
editor_data.find_view_id,
)
}
}
}
@ -255,6 +259,7 @@ pub fn to_data(
event_sink: ExtEventSink,
) -> LapceEditorData {
let editor_data = LapceEditorData::new(
None,
None,
Some(editor_tab_id),
self.content.clone(),

View File

@ -43,6 +43,12 @@
pub use lapce_core::syntax::Syntax;
use lsp_types::CodeActionOrCommand;
use lsp_types::CompletionTextEdit;
use lsp_types::DocumentChangeOperation;
use lsp_types::DocumentChanges;
use lsp_types::OneOf;
use lsp_types::TextEdit;
use lsp_types::Url;
use lsp_types::WorkspaceEdit;
use lsp_types::{
CodeActionResponse, CompletionItem, DiagnosticSeverity, GotoDefinitionResponse,
Location, Position,
@ -218,6 +224,53 @@ fn has_hover(&self) -> bool {
self.hover.status != HoverStatus::Inactive && !self.hover.is_empty()
}
pub fn run_code_action(&mut self, action: &CodeActionOrCommand) {
if let BufferContent::File(path) = &self.editor.content {
match action {
CodeActionOrCommand::Command(_cmd) => {}
CodeActionOrCommand::CodeAction(action) => {
if let Some(edit) = action.edit.as_ref() {
if let Some(edits) = workspce_edits(edit) {
if let Some(edits) =
edits.get(&Url::from_file_path(&path).unwrap())
{
let path = path.clone();
let doc = self
.main_split
.open_docs
.get_mut(&path)
.unwrap();
let edits: Vec<(
lapce_core::selection::Selection,
&str,
)> = edits
.iter()
.map(|edit| {
let selection =
lapce_core::selection::Selection::region(
doc.buffer().offset_of_position(
&edit.range.start,
),
doc.buffer().offset_of_position(
&edit.range.end,
),
);
(selection, edit.new_text.as_str())
})
.collect();
self.main_split.edit(
&path,
&edits,
lapce_core::editor::EditType::Other,
);
}
}
}
}
}
}
}
pub fn apply_completion_item(&mut self, item: &CompletionItem) -> Result<()> {
let additional_edit: Option<Vec<_>> =
item.additional_text_edits.as_ref().map(|edits| {
@ -1628,36 +1681,11 @@ fn run_focus_command(
));
}
ShowCodeActions => {
if let Some(actions) = self.current_code_actions() {
if !actions.is_empty() {
let mut menu = druid::Menu::new("");
for action in actions.iter() {
let title = match action {
CodeActionOrCommand::Command(c) => c.title.clone(),
CodeActionOrCommand::CodeAction(a) => {
a.title.clone()
}
};
let mut item = druid::MenuItem::new(title);
item = item.command(Command::new(
LAPCE_UI_COMMAND,
LapceUICommand::RunCodeAction(action.clone()),
Target::Widget(*self.main_split.tab_id),
));
menu = menu.entry(item);
}
let offset = self.editor.new_cursor.offset();
let point = self.doc.point_of_offset(
ctx.text(),
offset,
self.config.editor.font_size,
&self.config,
);
let point = ctx.to_window(point);
ctx.show_context_menu::<LapceData>(menu, point);
}
}
ctx.submit_command(Command::new(
LAPCE_UI_COMMAND,
LapceUICommand::ShowCodeActions(None),
Target::Widget(self.editor.editor_id),
));
}
GotoDefinition => {
let offset = self.editor.new_cursor.offset();
@ -1819,7 +1847,7 @@ fn run_focus_command(
Target::Widget(*self.main_split.tab_id),
));
}
if let Some(find_view_id) = self.editor.find_view_id {
if let Some((find_view_id, _)) = self.editor.find_view_id {
ctx.submit_command(Command::new(
LAPCE_COMMAND,
LapceCommand {
@ -2089,3 +2117,45 @@ fn process_get_references(
);
Ok(())
}
fn workspce_edits(edit: &WorkspaceEdit) -> Option<HashMap<Url, Vec<TextEdit>>> {
if let Some(changes) = edit.changes.as_ref() {
return Some(changes.clone());
}
let changes = edit.document_changes.as_ref()?;
let edits = match changes {
DocumentChanges::Edits(edits) => edits
.iter()
.map(|e| {
(
e.text_document.uri.clone(),
e.edits
.iter()
.map(|e| match e {
OneOf::Left(e) => e.clone(),
OneOf::Right(e) => e.text_edit.clone(),
})
.collect(),
)
})
.collect::<HashMap<Url, Vec<TextEdit>>>(),
DocumentChanges::Operations(ops) => ops
.iter()
.filter_map(|o| match o {
DocumentChangeOperation::Op(_op) => None,
DocumentChangeOperation::Edit(e) => Some((
e.text_document.uri.clone(),
e.edits
.iter()
.map(|e| match e {
OneOf::Left(e) => e.clone(),
OneOf::Right(e) => e.text_edit.clone(),
})
.collect(),
)),
})
.collect::<HashMap<Url, Vec<TextEdit>>>(),
};
Some(edits)
}

View File

@ -20,13 +20,13 @@
use crate::command::CommandKind;
use crate::data::{LapceWorkspace, LapceWorkspaceType};
use crate::document::BufferContent;
use crate::editor::EditorLocationNew;
use crate::{
command::LAPCE_UI_COMMAND,
command::{CommandExecuted, LAPCE_COMMAND},
command::{LapceCommand, LapceUICommand},
config::Config,
data::{FocusArea, LapceMainSplitData, LapceTabData, PanelKind},
editor::EditorLocationNew,
find::Find,
keypress::{KeyPressData, KeyPressFocus},
proxy::LapceProxy,

View File

@ -263,7 +263,7 @@ fn event(
Event::Command(cmd) if cmd.is(LAPCE_UI_COMMAND) => {
let command = cmd.get_unchecked(LAPCE_UI_COMMAND);
match command {
LapceUICommand::ShowCodeActions => {
LapceUICommand::ShowCodeActions(_) => {
data.main_split.show_code_actions = true;
data.main_split.current_code_actions = 0;
ctx.request_focus();

View File

@ -17,7 +17,7 @@
movement::Movement,
};
use lapce_data::command::CommandKind;
use lapce_data::data::EditorView;
use lapce_data::data::{EditorView, LapceData};
use lapce_data::document::{BufferContent, LocalBufferKind};
use lapce_data::keypress::KeyPressFocus;
use lapce_data::{
@ -30,7 +30,7 @@
menu::MenuItem,
panel::PanelPosition,
};
use lsp_types::DiagnosticSeverity;
use lsp_types::{CodeActionOrCommand, DiagnosticSeverity};
pub mod container;
pub mod gutter;
@ -42,6 +42,7 @@
pub struct LapceEditor {
view_id: WidgetId,
editor_id: WidgetId,
placeholder: Option<String>,
mouse_pos: Point,
@ -52,9 +53,10 @@ pub struct LapceEditor {
}
impl LapceEditor {
pub fn new(view_id: WidgetId) -> Self {
pub fn new(view_id: WidgetId, editor_id: WidgetId) -> Self {
Self {
view_id,
editor_id,
placeholder: None,
mouse_pos: Point::ZERO,
mouse_hover_timer: TimerToken::INVALID,
@ -1688,6 +1690,10 @@ fn paint_wave_line(
}
impl Widget<LapceTabData> for LapceEditor {
fn id(&self) -> Option<WidgetId> {
Some(self.editor_id)
}
fn event(
&mut self,
ctx: &mut EventCtx,
@ -1751,6 +1757,57 @@ fn event(
data.update_from_editor_buffer_data(editor_data, &editor, &doc);
}
}
Event::Command(cmd) if cmd.is(LAPCE_UI_COMMAND) => {
let cmd = cmd.get_unchecked(LAPCE_UI_COMMAND);
if let LapceUICommand::ShowCodeActions(point) = cmd {
let editor_data = data.editor_view_content(self.view_id);
if let Some(actions) = editor_data.current_code_actions() {
if !actions.is_empty() {
let mut menu = druid::Menu::new("");
for action in actions.iter() {
let title = match action {
CodeActionOrCommand::Command(c) => {
c.title.clone()
}
CodeActionOrCommand::CodeAction(a) => {
a.title.clone()
}
};
let mut item = druid::MenuItem::new(title);
item = item.command(Command::new(
LAPCE_UI_COMMAND,
LapceUICommand::RunCodeAction(action.clone()),
Target::Widget(editor_data.view_id),
));
menu = menu.entry(item);
}
let point = point.unwrap_or_else(|| {
let offset = editor_data.editor.new_cursor.offset();
let (line, col) = editor_data
.doc
.buffer()
.offset_to_line_col(offset);
let x = editor_data
.doc
.point_of_line_col(
ctx.text(),
line,
col,
editor_data.config.editor.font_size,
&editor_data.config,
)
.x;
let y = editor_data.config.editor.line_height as f64
* (line + 1) as f64;
ctx.to_window(Point::new(x, y))
});
ctx.show_context_menu::<LapceData>(menu, point);
}
}
}
}
_ => (),
}
}

View File

@ -22,11 +22,11 @@ pub struct LapceEditorContainer {
}
impl LapceEditorContainer {
pub fn new(view_id: WidgetId) -> Self {
pub fn new(view_id: WidgetId, editor_id: WidgetId) -> Self {
let scroll_id = WidgetId::next();
let gutter = LapceEditorGutter::new(view_id);
let gutter = LapcePadding::new((10.0, 0.0, 0.0, 0.0), gutter);
let editor = LapceEditor::new(view_id);
let editor = LapceEditor::new(view_id, editor_id);
let editor = LapceIdentityWrapper::wrap(
LapceScrollNew::new(editor).vertical().horizontal(),
scroll_id,

View File

@ -5,12 +5,10 @@
LifeCycleCtx, PaintCtx, Point, Rect, RenderContext, Size, Target, UpdateCtx,
Widget, WidgetId,
};
use lapce_core::{buffer::DiffLines, command::FocusCommand};
use lapce_core::buffer::DiffLines;
use lapce_data::{
command::{
CommandKind, LapceCommand, LapceUICommand, LAPCE_COMMAND, LAPCE_UI_COMMAND,
},
config::{Config, LapceTheme},
command::{LapceUICommand, LAPCE_UI_COMMAND},
config::LapceTheme,
data::{EditorView, LapceTabData},
editor::{LapceEditorBufferData, Syntax},
};
@ -51,15 +49,20 @@ fn event(
if rect.contains(self.mouse_down_pos)
&& rect.contains(mouse_event.pos)
{
let line_height = data.config.editor.line_height as f64;
let offset = data.editor.new_cursor.offset();
let (line, _) =
data.doc.buffer().offset_to_line_col(offset);
ctx.submit_command(Command::new(
LAPCE_COMMAND,
LapceCommand {
kind: CommandKind::Focus(
FocusCommand::ShowCodeActions,
),
data: None,
},
Target::Widget(*data.main_split.tab_id),
LAPCE_UI_COMMAND,
LapceUICommand::ShowCodeActions(Some(
ctx.to_window(Point::new(
rect.x0,
(line + 1) as f64 * line_height
- data.editor.scroll_offset.y,
)),
)),
Target::Widget(data.editor.editor_id),
))
}
}

View File

@ -53,7 +53,7 @@ fn clear_child(&mut self, ctx: &mut EventCtx, data: &mut LapceTabData) {
let editor_tab = data.main_split.editor_tabs.get(&self.widget_id).unwrap();
for child in editor_tab.children.iter() {
match child {
EditorTabChild::Editor(view_id, _) => {
EditorTabChild::Editor(view_id, _, _) => {
data.main_split.editors.remove(view_id);
}
}
@ -121,7 +121,7 @@ pub fn remove_child(
};
if delete {
match removed_child {
EditorTabChild::Editor(view_id, _) => {
EditorTabChild::Editor(view_id, _, _) => {
data.main_split.editors.remove(&view_id);
}
}
@ -597,7 +597,7 @@ fn paint(
if !(ctx.is_hot() && self.rect.contains(mouse_pos)) {
// See if any of the children are dirty
let is_pristine = match &editor_tab.children[i] {
EditorTabChild::Editor(editor_id, _) => {
EditorTabChild::Editor(editor_id, _, _) => {
let doc = data.main_split.editor_doc(*editor_id);
doc.buffer().is_pristine()
}

View File

@ -350,7 +350,7 @@ fn layout(
let mut text = "".to_string();
let mut svg = get_svg("default_file.svg").unwrap();
match child {
EditorTabChild::Editor(view_id, _) => {
EditorTabChild::Editor(view_id, _, _) => {
let editor = data.main_split.editors.get(view_id).unwrap();
if let BufferContent::File(path) = &editor.content {
svg = file_svg_new(path);

View File

@ -39,8 +39,8 @@ pub fn editor_tab_child_widget(
child: &EditorTabChild,
) -> Box<dyn Widget<LapceTabData>> {
match child {
EditorTabChild::Editor(view_id, find_view_id) => {
LapceEditorView::new(*view_id, *find_view_id).boxed()
EditorTabChild::Editor(view_id, editor_id, find_view_id) => {
LapceEditorView::new(*view_id, *editor_id, *find_view_id).boxed()
}
}
}
@ -48,12 +48,15 @@ pub fn editor_tab_child_widget(
impl LapceEditorView {
pub fn new(
view_id: WidgetId,
find_view_id: Option<WidgetId>,
editor_id: WidgetId,
find_view_id: Option<(WidgetId, WidgetId)>,
) -> LapceEditorView {
let header = LapceEditorHeader::new(view_id);
let editor = LapceEditorContainer::new(view_id);
let find =
find_view_id.map(|id| WidgetPod::new(FindBox::new(id, view_id)).boxed());
let editor = LapceEditorContainer::new(view_id, editor_id);
let find = find_view_id.map(|(find_view_id, find_editor_id)| {
WidgetPod::new(FindBox::new(find_view_id, find_editor_id, view_id))
.boxed()
});
Self {
view_id,
header: WidgetPod::new(header),
@ -152,6 +155,9 @@ pub fn handle_lapce_ui_command(
env: &Env,
) {
match cmd {
LapceUICommand::RunCodeAction(action) => {
data.run_code_action(action);
}
LapceUICommand::EnsureCursorVisible(position) => {
self.ensure_cursor_visible(
ctx,

View File

@ -20,8 +20,12 @@ pub struct FindBox {
}
impl FindBox {
pub fn new(view_id: WidgetId, parent_view_id: WidgetId) -> Self {
let input = LapceEditorView::new(view_id, None)
pub fn new(
view_id: WidgetId,
editor_id: WidgetId,
parent_view_id: WidgetId,
) -> Self {
let input = LapceEditorView::new(view_id, editor_id, None)
.hide_header()
.hide_gutter()
.padding((10.0, 5.0));

View File

@ -40,10 +40,14 @@ pub fn new_split(data: &LapceTabData) -> LapceSplitNew {
};
let keymap = LapceScrollNew::new(keymap);
let input = LapceEditorView::new(data.settings.keymap_view_id, None)
.hide_header()
.hide_gutter()
.padding((15.0, 15.0));
let input = LapceEditorView::new(
data.settings.keymap_view_id,
WidgetId::next(),
None,
)
.hide_header()
.hide_gutter()
.padding((15.0, 15.0));
let header = LapceKeymapHeader::new();
let split = LapceSplitNew::new(data.settings.keymap_split_id)
.horizontal()

View File

@ -239,10 +239,11 @@ pub fn new(data: &LapceTabData) -> Self {
.editors
.get(&data.palette.preview_editor)
.unwrap();
let input = LapceEditorView::new(data.palette.input_editor, None)
.hide_header()
.hide_gutter()
.padding(10.0);
let input =
LapceEditorView::new(data.palette.input_editor, WidgetId::next(), None)
.hide_header()
.hide_gutter()
.padding(10.0);
let content = LapceIdentityWrapper::wrap(
LapceScrollNew::new(
NewPaletteContent::new().lens(PaletteViewLens).boxed(),
@ -250,7 +251,8 @@ pub fn new(data: &LapceTabData) -> Self {
.vertical(),
data.palette.scroll_id,
);
let preview = LapceEditorView::new(preview_editor.view_id, None);
let preview =
LapceEditorView::new(preview_editor.view_id, WidgetId::next(), None);
Self {
content_size: Size::ZERO,
input: WidgetPod::new(input.boxed()),

View File

@ -166,9 +166,10 @@ struct FilePickerPwd {
impl FilePickerPwd {
pub fn new(data: &LapceTabData) -> Self {
let input = LapceEditorView::new(data.picker.editor_view_id, None)
.hide_header()
.hide_gutter();
let input =
LapceEditorView::new(data.picker.editor_view_id, WidgetId::next(), None)
.hide_header()
.hide_gutter();
Self {
icons: Vec::new(),
input: WidgetPod::new(input.boxed()),

View File

@ -2,7 +2,7 @@
piet::{Text, TextAttribute, TextLayout as PietTextLayout, TextLayoutBuilder},
BoxConstraints, Command, Cursor, Data, Env, Event, EventCtx, FontWeight,
LayoutCtx, LifeCycle, LifeCycleCtx, MouseEvent, PaintCtx, Point, RenderContext,
Size, Target, UpdateCtx, Widget, WidgetExt,
Size, Target, UpdateCtx, Widget, WidgetExt, WidgetId,
};
use lapce_data::{
command::{LapceUICommand, LAPCE_UI_COMMAND},
@ -26,7 +26,7 @@ pub fn new_search_panel(data: &LapceTabData) -> LapcePanel {
.editors
.get(&data.search.editor_view_id)
.unwrap();
let input = LapceEditorView::new(editor_data.view_id, None)
let input = LapceEditorView::new(editor_data.view_id, WidgetId::next(), None)
.hide_header()
.hide_gutter()
.padding((15.0, 15.0));

View File

@ -506,10 +506,14 @@ pub fn new_split(kind: LapceSettingsKind, data: &LapceTabData) -> LapceSplitNew
.boxed(),
);
let _input = LapceEditorView::new(data.settings.settings_view_id, None)
.hide_header()
.hide_gutter()
.padding((15.0, 15.0));
let _input = LapceEditorView::new(
data.settings.settings_view_id,
WidgetId::next(),
None,
)
.hide_header()
.hide_gutter()
.padding((15.0, 15.0));
let split = LapceSplitNew::new(data.settings.settings_split_id)
.horizontal()
@ -732,9 +736,10 @@ pub fn new(
);
doc.reload(Rope::from(&input), true);
data.main_split.value_docs.insert(name, Arc::new(doc));
let editor = LapceEditorData::new(None, None, content, &data.config);
let editor =
LapceEditorData::new(None, None, None, content, &data.config);
let view_id = editor.view_id;
let input = LapceEditorView::new(editor.view_id, None)
let input = LapceEditorView::new(editor.view_id, editor.editor_id, None)
.hide_header()
.hide_gutter()
.padding((5.0, 0.0, 50.0, 0.0));

View File

@ -26,11 +26,12 @@ pub fn new_source_control_panel(data: &LapceTabData) -> LapcePanel {
.editors
.get(&data.source_control.editor_view_id)
.unwrap();
let input = LapceEditorView::new(editor_data.view_id, None)
.hide_header()
.hide_gutter()
.set_placeholder("Commit Message".to_string())
.padding((15.0, 15.0));
let input =
LapceEditorView::new(editor_data.view_id, editor_data.editor_id, None)
.hide_header()
.hide_gutter()
.set_placeholder("Commit Message".to_string())
.padding((15.0, 15.0));
let content = SourceControlFileList::new(data.source_control.file_list_id);
LapcePanel::new(
PanelKind::SourceControl,

View File

@ -59,9 +59,13 @@ pub fn split_content_widget(
let mut editor_tab = LapceEditorTab::new(editor_tab_data.widget_id);
for child in editor_tab_data.children.iter() {
match child {
EditorTabChild::Editor(view_id, find_view_id) => {
let editor =
LapceEditorView::new(*view_id, *find_view_id).boxed();
EditorTabChild::Editor(view_id, editor_id, find_view_id) => {
let editor = LapceEditorView::new(
*view_id,
*editor_id,
*find_view_id,
)
.boxed();
editor_tab = editor_tab.with_child(editor);
}
}
@ -740,6 +744,7 @@ pub fn split_editor(
let view_id = self.children[index].widget.id();
let from_editor = data.main_split.editors.get(&view_id).unwrap();
let mut editor_data = LapceEditorData::new(
None,
None,
Some(self.split_id),
from_editor.content.clone(),
@ -756,8 +761,11 @@ pub fn split_editor(
Target::Widget(editor_data.view_id),
));
let editor =
LapceEditorView::new(editor_data.view_id, editor_data.find_view_id);
let editor = LapceEditorView::new(
editor_data.view_id,
editor_data.editor_id,
editor_data.find_view_id,
);
self.insert_flex_child(
index + 1,
editor.boxed(),

View File

@ -983,7 +983,7 @@ fn handle_event(
ctx.set_handled();
}
LapceUICommand::ShowCodeActions
LapceUICommand::ShowCodeActions(_)
| LapceUICommand::CancelCodeActions => {
self.code_action.event(ctx, event, data, env);
}