Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

terminal: Respect word boundaries after tree branches (#62076)

Ayushf25b256f2c10
diff --git a/crates/terminal/src/alacritty.rs b/crates/terminal/src/alacritty.rs
index 6a8e9d0dd2f..4cf8fe1d583 100644
--- a/crates/terminal/src/alacritty.rs
+++ b/crates/terminal/src/alacritty.rs
@@ -17,7 +17,7 @@ use alacritty_terminal::{
},
sync::FairMutex,
term::{
- Config, Osc52, RenderableCursor, Term, TermMode,
+ Config, Osc52, RenderableCursor, SEMANTIC_ESCAPE_CHARS, Term, TermMode,
cell::{Cell as AlacCell, Flags, Hyperlink as AlacHyperlink},
search::{Match, RegexIter, RegexSearch},
},
@@ -123,6 +123,7 @@ pub(super) fn display_only_term_config(
Config {
scrolling_history,
default_cursor_style: alacritty_cursor_style(cursor_shape),
+ semantic_escape_chars: format!("{SEMANTIC_ESCAPE_CHARS}─"),
osc52: Osc52::Disabled,
..Config::default()
}
@@ -135,6 +136,7 @@ pub(super) fn pty_term_config(
Config {
scrolling_history,
default_cursor_style: alacritty_cursor_style(cursor_shape),
+ semantic_escape_chars: format!("{SEMANTIC_ESCAPE_CHARS}─"),
..Config::default()
}
}
@@ -1101,4 +1103,23 @@ mod tests {
}
);
}
+
+ #[test]
+ fn semantic_selection_stops_at_tree_branch() {
+ let config = pty_term_config(1000, SettingsCursorShape::default());
+ let (events_tx, _events_rx) = futures::channel::mpsc::unbounded();
+ let mut term = Term::new(config, &TerminalBounds::default(), ZedListener(events_tx));
+ for character in "└─zms-demo.target".chars() {
+ term.input(character);
+ }
+
+ let selection = Selection::new(
+ SelectionType::Semantic,
+ Point::new(0, 2),
+ SelectionSide::Left,
+ );
+ set_selection(&mut term, Some(&selection));
+
+ assert_eq!(selection_text(&term).as_deref(), Some("zms-demo.target"));
+ }
}