SSH remote ui (#15129)

Still TODO:
* [x] hide this UI unless you have some ssh projects in settings
* [x] add the "open folder" flow with the new open picker
* [ ] integrate with recent projects / workspace restoration

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin
2024-07-26 16:45:44 -06:00
committed by GitHub
parent be86852f95
commit 3e31955b7f
23 changed files with 1162 additions and 436 deletions
+8 -2
View File
@@ -109,6 +109,7 @@ pub struct DisplayMap {
crease_map: CreaseMap,
fold_placeholder: FoldPlaceholder,
pub clip_at_line_ends: bool,
pub(crate) masked: bool,
}
impl DisplayMap {
@@ -156,6 +157,7 @@ impl DisplayMap {
text_highlights: Default::default(),
inlay_highlights: Default::default(),
clip_at_line_ends: false,
masked: false,
}
}
@@ -182,6 +184,7 @@ impl DisplayMap {
text_highlights: self.text_highlights.clone(),
inlay_highlights: self.inlay_highlights.clone(),
clip_at_line_ends: self.clip_at_line_ends,
masked: self.masked,
fold_placeholder: self.fold_placeholder.clone(),
}
}
@@ -499,6 +502,7 @@ pub struct DisplaySnapshot {
text_highlights: TextHighlights,
inlay_highlights: InlayHighlights,
clip_at_line_ends: bool,
masked: bool,
pub(crate) fold_placeholder: FoldPlaceholder,
}
@@ -650,6 +654,7 @@ impl DisplaySnapshot {
.chunks(
display_row.0..self.max_point().row().next_row().0,
false,
self.masked,
Highlights::default(),
)
.map(|h| h.text)
@@ -657,9 +662,9 @@ impl DisplaySnapshot {
/// Returns text chunks starting at the end of the given display row in reverse until the start of the file
pub fn reverse_text_chunks(&self, display_row: DisplayRow) -> impl Iterator<Item = &str> {
(0..=display_row.0).rev().flat_map(|row| {
(0..=display_row.0).rev().flat_map(move |row| {
self.block_snapshot
.chunks(row..row + 1, false, Highlights::default())
.chunks(row..row + 1, false, self.masked, Highlights::default())
.map(|h| h.text)
.collect::<Vec<_>>()
.into_iter()
@@ -676,6 +681,7 @@ impl DisplaySnapshot {
self.block_snapshot.chunks(
display_rows.start.0..display_rows.end.0,
language_aware,
self.masked,
Highlights {
text_highlights: Some(&self.text_highlights),
inlay_highlights: Some(&self.inlay_highlights),
+15 -1
View File
@@ -23,6 +23,7 @@ use text::Edit;
use ui::ElementId;
const NEWLINES: &[u8] = &[b'\n'; u8::MAX as usize];
const BULLETS: &str = "********************************************************************************************************************************";
/// Tracks custom blocks such as diagnostics that should be displayed within buffer.
///
@@ -285,6 +286,7 @@ pub struct BlockChunks<'a> {
input_chunk: Chunk<'a>,
output_row: u32,
max_output_row: u32,
masked: bool,
}
#[derive(Clone)]
@@ -893,6 +895,7 @@ impl BlockSnapshot {
self.chunks(
0..self.transforms.summary().output_rows,
false,
false,
Highlights::default(),
)
.map(|chunk| chunk.text)
@@ -903,6 +906,7 @@ impl BlockSnapshot {
&'a self,
rows: Range<u32>,
language_aware: bool,
masked: bool,
highlights: Highlights<'a>,
) -> BlockChunks<'a> {
let max_output_row = cmp::min(rows.end, self.transforms.summary().output_rows);
@@ -941,6 +945,7 @@ impl BlockSnapshot {
transforms: cursor,
output_row: rows.start,
max_output_row,
masked,
}
}
@@ -1229,12 +1234,20 @@ impl<'a> Iterator for BlockChunks<'a> {
let (prefix_rows, prefix_bytes) =
offset_for_row(self.input_chunk.text, transform_end - self.output_row);
self.output_row += prefix_rows;
let (prefix, suffix) = self.input_chunk.text.split_at(prefix_bytes);
let (mut prefix, suffix) = self.input_chunk.text.split_at(prefix_bytes);
self.input_chunk.text = suffix;
if self.output_row == transform_end {
self.transforms.next(&());
}
if self.masked {
// Not great for multibyte text because to keep cursor math correct we
// need to have the same number of bytes in the input as output.
let chars = prefix.chars().count();
let bullet_len = chars;
prefix = &BULLETS[..bullet_len];
}
Some(Chunk {
text: prefix,
..self.input_chunk.clone()
@@ -2048,6 +2061,7 @@ mod tests {
.chunks(
start_row as u32..blocks_snapshot.max_point().row + 1,
false,
false,
Highlights::default(),
)
.map(|chunk| chunk.text)
+5 -9
View File
@@ -480,7 +480,6 @@ pub struct Editor {
mode: EditorMode,
show_breadcrumbs: bool,
show_gutter: bool,
redact_all: bool,
show_line_numbers: Option<bool>,
show_git_diff_gutter: Option<bool>,
show_code_actions: Option<bool>,
@@ -1803,7 +1802,6 @@ impl Editor {
show_code_actions: None,
show_runnables: None,
show_wrap_guides: None,
redact_all: false,
show_indent_guides,
placeholder_text: None,
highlight_order: 0,
@@ -10420,9 +10418,11 @@ impl Editor {
cx.notify();
}
pub fn set_redact_all(&mut self, redact_all: bool, cx: &mut ViewContext<Self>) {
self.redact_all = redact_all;
cx.notify();
pub fn set_masked(&mut self, masked: bool, cx: &mut ViewContext<Self>) {
if self.display_map.read(cx).masked != masked {
self.display_map.update(cx, |map, _| map.masked = masked);
}
cx.notify()
}
pub fn set_show_wrap_guides(&mut self, show_wrap_guides: bool, cx: &mut ViewContext<Self>) {
@@ -11108,10 +11108,6 @@ impl Editor {
display_snapshot: &DisplaySnapshot,
cx: &WindowContext,
) -> Vec<Range<DisplayPoint>> {
if self.redact_all {
return vec![DisplayPoint::zero()..display_snapshot.max_point()];
}
display_snapshot
.buffer_snapshot
.redacted_ranges(search_range, |file| {