Skip to content

Commit

Permalink
fix: trigger hover when renaming (#1954)
Browse files Browse the repository at this point in the history
* fix: trigger hover when renaming

* fix: trigger hover when renaming
  • Loading branch information
tk103331 committed Jan 11, 2023
1 parent 1c57875 commit acf1de5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lapce-data/src/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct RenameData {
pub start: usize,
pub end: usize,
pub placeholder: String,
pub mouse_within: bool,
}

impl RenameData {
Expand All @@ -43,6 +44,7 @@ impl RenameData {
start: 0,
end: 0,
placeholder: "".to_string(),
mouse_within: false,
}
}

Expand All @@ -60,6 +62,7 @@ impl RenameData {
self.offset = offset;
self.from_editor = from_editor;
self.position = position;
self.mouse_within = false;
}

pub fn cancel(&mut self) {
Expand Down
2 changes: 2 additions & 0 deletions lapce-ui/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ impl LapceEditor {
if !editor_data.check_hover(ctx, offset, is_inside, within_scroll)
&& is_inside
&& within_scroll
&& !editor_data.rename.mouse_within
{
self.mouse_hover_timer = ctx.request_timer(
Duration::from_millis(config.editor.hover_delay),
Expand Down Expand Up @@ -2354,6 +2355,7 @@ impl Widget<LapceTabData> for LapceEditor {
&data.config,
);
editor_data.update_hover(ctx, offset);

data.update_from_editor_buffer_data(editor_data, &editor, &doc);
} else if self.drag_timer == *id {
let doc = data.main_split.editor_doc(self.view_id);
Expand Down
4 changes: 4 additions & 0 deletions lapce-ui/src/tab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,10 @@ impl LapceTab {
_env: &Env,
) {
match event {
Event::MouseMove(mouse) => {
Arc::make_mut(&mut data.rename).mouse_within = data.rename.active
&& self.rename.layout_rect().contains(mouse.pos);
}
Event::MouseDown(mouse) => {
if !ctx.is_handled() && mouse.button.is_left() {
if let Some(position) = self.bar_hit_test(mouse.pos) {
Expand Down

0 comments on commit acf1de5

Please sign in to comment.