aboutsummaryrefslogtreecommitdiff
path: root/src/client/shell/actions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/shell/actions.rs')
-rw-r--r--src/client/shell/actions.rs99
1 files changed, 1 insertions, 98 deletions
diff --git a/src/client/shell/actions.rs b/src/client/shell/actions.rs
index 119988f6..7fb2b6ce 100644
--- a/src/client/shell/actions.rs
+++ b/src/client/shell/actions.rs
@@ -294,54 +294,6 @@ impl ClientShellState {
);
}
- pub(super) fn request_word_selection(
- &mut self,
- hit: &PaneHit,
- viewport_row: u16,
- col: u16,
- outcome: &mut ClientShellInput,
- ) {
- let absolute_row = crate::selection::absolute_row_for_viewport(viewport_row, hit.scroll);
- let content_revision = self
- .pane_surface
- .as_ref()
- .and_then(|surface| {
- surface
- .panes
- .iter()
- .find(|pane| pane.pane_id == hit.pane_id)
- })
- .map(|pane| pane.content_revision);
- self.word_selection_generation = self.word_selection_generation.saturating_add(1);
- let generation = self.word_selection_generation;
- self.pending_word_selection = Some(generation);
- if !self.push_endpoint_method_with_kind(
- crate::api::schema::Method::PaneSelectionRead(
- crate::api::schema::PaneSelectionReadParams {
- pane_id: hit.pane_id.clone(),
- anchor: crate::api::schema::PaneTextPoint {
- row: absolute_row,
- col: 0,
- },
- cursor: crate::api::schema::PaneTextPoint {
- row: absolute_row,
- col: hit.inner_rect.width.saturating_sub(1),
- },
- content_revision,
- },
- ),
- PendingEndpointKind::WordSelection {
- pane_id: hit.pane_id.clone(),
- absolute_row,
- col,
- generation,
- },
- outcome,
- ) {
- self.pending_word_selection = None;
- }
- }
-
pub(super) fn push_endpoint_method(
&mut self,
method: crate::api::schema::Method,
@@ -666,58 +618,9 @@ impl ClientShellState {
PendingEndpointKind::WordSelection {
pane_id,
absolute_row,
- col,
generation,
} => {
- if self.pending_word_selection != Some(generation)
- || self.snapshot.as_deref().is_none_or(|snapshot| {
- !snapshot.panes.iter().any(|pane| pane.pane_id == pane_id)
- })
- {
- return (false, Vec::new());
- }
- self.pending_word_selection = None;
- let row_text = match result {
- Ok(crate::api::schema::ResponseResult::PaneSelection {
- pane_id: returned_pane_id,
- text,
- }) if returned_pane_id == pane_id => text,
- Ok(crate::api::schema::ResponseResult::PaneSelection { .. }) => {
- return (false, Vec::new())
- }
- Ok(_) => {
- self.endpoint_error = Some(
- "endpoint returned an unexpected word-selection result".to_owned(),
- );
- return (true, Vec::new());
- }
- Err(_) => return (true, Vec::new()),
- };
- let Some((start_col, end_col)) =
- crate::app::actions::word_bounds_at_column(&row_text, col)
- else {
- self.selection = None;
- return (true, Vec::new());
- };
- let mut selection = crate::selection::Selection::absolute_range(
- pane_id,
- (absolute_row, start_col),
- (absolute_row, end_col),
- );
- if !selection.finish() {
- return (false, Vec::new());
- }
- self.selection = Some(selection);
- self.selection_autoscroll = None;
- self.selection_autoscroll_deadline = None;
- if !self.config.copy_on_select {
- return (true, Vec::new());
- }
- self.selection_highlight_clear_deadline =
- Some(std::time::Instant::now() + std::time::Duration::from_millis(500));
- let mut outcome = ClientShellInput::default();
- self.request_selection_copy(&mut outcome, false);
- return (true, outcome.actions);
+ return self.complete_word_selection_row(pane_id, absolute_row, generation, result);
}
PendingEndpointKind::PaneLinkActivate {
pane_id,