Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ When handing work off to another person or to the user, include:
- Favor explicitness over cleverness.
- Reuse existing patterns already present in the workspace.
- Prefer modular, composable changes over tightly coupled one-off implementations.
- Avoid glob imports such as `use foo::*` or `use super::*`; import the specific items needed.
- Add tests near the affected code when the repository already has a local testing pattern for that area.
- Put unit tests at the bottom of the file when adding or updating inline tests.
- Preserve consistency with existing naming, error handling, and module organization.
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions crates/gpui_term/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::{
reserve_left_padding_without_line_numbers, should_relayout_for_mode_change,
should_show_line_numbers,
},
scrollbar::{
scrolling::{
SCROLLBAR_WIDTH, ScrollbarLayoutState, overlay_scrollbar_layout_state,
paint_overlay_scrollbar, scroll_offset_for_drag_delta,
scroll_offset_for_line_coord_centered, scroll_offset_for_thumb_center_y,
Expand Down Expand Up @@ -3665,7 +3665,10 @@ fn terminal_view_bounds_for_suggestions_overlay(

#[cfg(test)]
mod suggestions_overlay_desc_tests {
use super::*;
use gpui::{Bounds, point, px, size};

use super::{SuggestionsOverlayHitTest, compute_suggestions_overlay_layout};
use crate::terminal::TerminalBounds;

#[test]
fn layout_does_not_reserve_desc_row_when_empty() {
Expand Down Expand Up @@ -3882,7 +3885,16 @@ mod suggestions_overlay_desc_tests {

#[cfg(test)]
mod tests {
use super::*;
use std::ops::RangeInclusive;

use gpui::{Bounds, point, px, size};
use gpui_component::Theme;

use super::{
compute_terminal_layout_metrics, highlight_quads_for_range, placeholder_highlight_bgs,
snippet_placeholder_bg_quads,
};
use crate::{GridPoint, TerminalMode, view::line_number::should_relayout_for_mode_change};

#[test]
fn placeholder_highlight_colors_are_theme_derived() {
Expand Down
54 changes: 54 additions & 0 deletions crates/gpui_term/src/view/input.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use gpui::{Context, KeyDownEvent, ReadGlobal, Window};

use super::TerminalView;
use crate::{
settings::{CursorShape, TerminalSettings},
terminal::{Event, UserInput},
};

impl TerminalView {
pub(super) fn forward_keystroke_to_terminal(
&mut self,
event: &KeyDownEvent,
cx: &mut Context<Self>,
) {
let (handled, vi_mode_enabled) = self.terminal.update(cx, |term, cx| {
let handled = term.try_keystroke(
&event.keystroke,
TerminalSettings::global(cx).option_as_meta,
);
(handled, term.vi_mode_enabled())
});

if handled {
cx.stop_propagation();
// In terminal vi-mode, keystrokes are usually for scrollback/navigation, so don't
// force the view back to the bottom.
if !vi_mode_enabled {
self.snap_to_bottom_on_input(cx);
}
cx.emit(Event::UserInput(UserInput::Keystroke(
event.keystroke.clone(),
)));
}
}

pub(super) fn focus_in(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.terminal.update(cx, |terminal, _| {
terminal.set_cursor_shape(self.cursor_shape);
terminal.focus_in();
});
self.blink_cursors(self.blink.epoch, cx);
window.invalidate_character_coordinates();
cx.notify();
}

pub(super) fn focus_out(&mut self, _: &mut Window, cx: &mut Context<Self>) {
self.terminal.update(cx, |terminal, _| {
terminal.focus_out();
terminal.set_cursor_shape(CursorShape::Hollow);
});
self.suggestions.close();
cx.notify();
}
}
6 changes: 4 additions & 2 deletions crates/gpui_term/src/view/line_number.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::fmt::Write as _;
use std::fmt::Write;

use gpui::{App, Bounds, Pixels, TextAlign, TextRun, TextStyle, Window, point, px};
use gpui_component::ActiveTheme;
Expand Down Expand Up @@ -232,7 +232,9 @@ pub(crate) fn paint_line_numbers(

#[cfg(test)]
mod tests {
use super::*;
use gpui::{Pixels, px};

use super::{compute_line_number_layout, format_line_number};

#[test]
fn reserves_minimum_gutter_without_line_numbers() {
Expand Down
Loading
Loading