press the down key to move to the end of the line (#52)

This commit is contained in:
reya
2025-05-30 12:14:51 +07:00
committed by GitHub
parent 63191c16bd
commit 7cc512331b
6 changed files with 52 additions and 42 deletions

View File

@@ -503,6 +503,13 @@ impl InputState {
return;
}
// Handle moving below the last line
if direction == 1 && new_line_index == 0 && new_sub_line > 0 && lines.len() == 1 {
// Move cursor to the end of the text
self.move_to(self.text.len(), window, cx);
return;
}
if new_sub_line < 0 {
if new_line_index > 0 {
new_line_index -= 1;

View File

@@ -3,9 +3,10 @@ use std::{cell::RefCell, rc::Rc};
use gpui::{
actions, anchored, deferred, div, prelude::FluentBuilder as _, px, AnyElement, App, Bounds,
Context, Corner, DismissEvent, DispatchPhase, Element, ElementId, Entity, EventEmitter,
FocusHandle, Focusable, GlobalElementId, Hitbox, InteractiveElement as _, IntoElement,
KeyBinding, LayoutId, ManagedView, MouseButton, MouseDownEvent, ParentElement, Pixels, Point,
Render, ScrollHandle, StatefulInteractiveElement, Style, StyleRefinement, Styled, Window,
FocusHandle, Focusable, GlobalElementId, Hitbox, HitboxBehavior, InteractiveElement as _,
IntoElement, KeyBinding, LayoutId, ManagedView, MouseButton, MouseDownEvent, ParentElement,
Pixels, Point, Render, ScrollHandle, StatefulInteractiveElement, Style, StyleRefinement,
Styled, Window,
};
use crate::{Selectable, StyledExt as _};
@@ -378,7 +379,8 @@ impl<M: ManagedView> Element for Popover<M> {
.popover_layout_id
.map(|id| window.layout_bounds(id));
let hitbox = window.insert_hitbox(trigger_bounds.unwrap_or_default(), false);
let hitbox =
window.insert_hitbox(trigger_bounds.unwrap_or_default(), HitboxBehavior::Normal);
PrepaintState {
trigger_bounds,

View File

@@ -1,7 +1,7 @@
use gpui::{
px, relative, App, Axis, BorderStyle, Bounds, ContentMask, Corners, Edges, Element, ElementId,
EntityId, GlobalElementId, Hitbox, Hsla, IntoElement, IsZero as _, LayoutId, PaintQuad, Pixels,
Point, Position, ScrollHandle, ScrollWheelEvent, Size, Style, Window,
EntityId, GlobalElementId, Hitbox, HitboxBehavior, Hsla, IntoElement, IsZero as _, LayoutId,
PaintQuad, Pixels, Point, Position, ScrollHandle, ScrollWheelEvent, Size, Style, Window,
};
use crate::AxisExt;
@@ -96,7 +96,7 @@ impl Element for ScrollableMask {
size: bounds.size,
};
window.insert_hitbox(cover_bounds, false)
window.insert_hitbox(cover_bounds, HitboxBehavior::Normal)
}
fn paint(

View File

@@ -6,8 +6,9 @@ use std::{
use gpui::{
fill, point, px, relative, App, BorderStyle, Bounds, ContentMask, CursorStyle, Edges, Element,
EntityId, Hitbox, Hsla, IntoElement, MouseDownEvent, MouseMoveEvent, MouseUpEvent, PaintQuad,
Pixels, Point, Position, ScrollHandle, ScrollWheelEvent, UniformListScrollHandle, Window,
EntityId, Hitbox, HitboxBehavior, Hsla, IntoElement, MouseDownEvent, MouseMoveEvent,
MouseUpEvent, PaintQuad, Pixels, Point, Position, ScrollHandle, ScrollWheelEvent,
UniformListScrollHandle, Window,
};
use theme::ActiveTheme;
@@ -431,7 +432,7 @@ impl Element for Scrollbar {
cx: &mut App,
) -> Self::PrepaintState {
let hitbox = window.with_content_mask(Some(ContentMask { bounds }), |window| {
window.insert_hitbox(bounds, false)
window.insert_hitbox(bounds, HitboxBehavior::Normal)
});
let mut states = vec![];
@@ -569,7 +570,7 @@ impl Element for Scrollbar {
};
let bar_hitbox = window.with_content_mask(Some(ContentMask { bounds }), |window| {
window.insert_hitbox(bounds, false)
window.insert_hitbox(bounds, HitboxBehavior::Normal)
});
states.push(AxisPrepaintState {

View File

@@ -1,7 +1,7 @@
use gpui::{
canvas, div, point, prelude::FluentBuilder as _, px, AnyElement, App, Bounds, CursorStyle,
Decorations, Edges, Hsla, InteractiveElement as _, IntoElement, MouseButton, ParentElement,
Pixels, Point, RenderOnce, ResizeEdge, Size, Styled as _, Window,
Decorations, Edges, HitboxBehavior, Hsla, InteractiveElement as _, IntoElement, MouseButton,
ParentElement, Pixels, Point, RenderOnce, ResizeEdge, Size, Styled as _, Window,
};
use theme::ActiveTheme;
@@ -80,7 +80,7 @@ impl RenderOnce for WindowBorder {
point(px(0.0), px(0.0)),
window.window_bounds().get_bounds().size,
),
false,
HitboxBehavior::Normal,
)
},
move |_bounds, hitbox, window, _cx| {