chore(core): format rust code (#30954)
## Current Behavior Rust formatting isn't checked in CI ## Expected Behavior Rust formatting is checked in CI ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
d9cb931116
commit
981dd94671
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -94,7 +94,7 @@ jobs:
|
|||||||
pnpm nx run-many -t check-imports check-commit check-lock-files check-codeowners --parallel=1 --no-dte &
|
pnpm nx run-many -t check-imports check-commit check-lock-files check-codeowners --parallel=1 --no-dte &
|
||||||
pids+=($!)
|
pids+=($!)
|
||||||
|
|
||||||
pnpm nx affected --targets=lint,test,build,e2e,e2e-ci &
|
pnpm nx affected --targets=lint,test,build,e2e,e2e-ci,format-native &
|
||||||
pids+=($!)
|
pids+=($!)
|
||||||
|
|
||||||
for pid in "${pids[@]}"; do
|
for pid in "${pids[@]}"; do
|
||||||
|
|||||||
@ -2,3 +2,4 @@ pnpm check-lock-files
|
|||||||
pnpm check-commit
|
pnpm check-commit
|
||||||
pnpm documentation
|
pnpm documentation
|
||||||
pnpm pretty-quick --check
|
pnpm pretty-quick --check
|
||||||
|
pnpm nx format-native nx
|
||||||
@ -139,6 +139,19 @@
|
|||||||
"parallel": false
|
"parallel": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"test-native": {}
|
"test-native": {},
|
||||||
|
"format-native": {
|
||||||
|
"command": "cargo fmt",
|
||||||
|
"cache": true,
|
||||||
|
"options": {
|
||||||
|
"cwd": "{projectRoot}/src/native",
|
||||||
|
"args": ["--all", "--check"]
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"fix": {
|
||||||
|
"args": ["--all"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
|
use super::contains_glob_pattern;
|
||||||
use crate::native::glob::glob_group::GlobGroup;
|
use crate::native::glob::glob_group::GlobGroup;
|
||||||
use crate::native::glob::glob_parser::parse_glob;
|
use crate::native::glob::glob_parser::parse_glob;
|
||||||
|
use itertools::Either::{Left, Right};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use itertools::Either::{Left, Right};
|
|
||||||
use super::contains_glob_pattern;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum GlobType {
|
enum GlobType {
|
||||||
@ -120,15 +120,13 @@ pub fn partition_glob(glob: &str) -> anyhow::Result<(String, Vec<String>)> {
|
|||||||
let (leading_dir_segments, pattern_segments): (Vec<String>, _) = groups
|
let (leading_dir_segments, pattern_segments): (Vec<String>, _) = groups
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|group| !group.is_empty())
|
.filter(|group| !group.is_empty())
|
||||||
.partition_map(|group| {
|
.partition_map(|group| match &group[0] {
|
||||||
match &group[0] {
|
GlobGroup::NonSpecial(value) if !contains_glob_pattern(&value) && !has_patterns => {
|
||||||
GlobGroup::NonSpecial(value) if !contains_glob_pattern(&value) && !has_patterns => {
|
Left(value.to_string())
|
||||||
Left(value.to_string())
|
}
|
||||||
}
|
_ => {
|
||||||
_ => {
|
has_patterns = true;
|
||||||
has_patterns = true;
|
Right(group)
|
||||||
Right(group)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -267,7 +265,8 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_partition_glob_with_leading_dirs() {
|
fn should_partition_glob_with_leading_dirs() {
|
||||||
let (leading_dirs, globs) = super::partition_glob("dist/app/**/!(README|LICENSE).(js|ts)").unwrap();
|
let (leading_dirs, globs) =
|
||||||
|
super::partition_glob("dist/app/**/!(README|LICENSE).(js|ts)").unwrap();
|
||||||
assert_eq!(leading_dirs, "dist/app");
|
assert_eq!(leading_dirs, "dist/app");
|
||||||
assert_eq!(globs, ["!**/{README,LICENSE}.{js,ts}", "**/*.{js,ts}",]);
|
assert_eq!(globs, ["!**/{README,LICENSE}.{js,ts}", "**/*.{js,ts}",]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,12 +9,16 @@ pub fn hash(content: &[u8]) -> String {
|
|||||||
|
|
||||||
#[napi]
|
#[napi]
|
||||||
pub fn hash_array(input: Vec<Option<String>>) -> String {
|
pub fn hash_array(input: Vec<Option<String>>) -> String {
|
||||||
let joined = input.iter().filter_map(|s| {
|
let joined = input
|
||||||
if s.is_none() {
|
.iter()
|
||||||
trace!("Encountered None value in hash_array input: {:?}", input);
|
.filter_map(|s| {
|
||||||
}
|
if s.is_none() {
|
||||||
s.as_deref()
|
trace!("Encountered None value in hash_array input: {:?}", input);
|
||||||
}).collect::<Vec<_>>().join(",");
|
}
|
||||||
|
s.as_deref()
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join(",");
|
||||||
let content = joined.as_bytes();
|
let content = joined.as_bytes();
|
||||||
hash(content)
|
hash(content)
|
||||||
}
|
}
|
||||||
@ -41,7 +45,7 @@ pub fn hash_file_path<P: AsRef<Path>>(path: P) -> Option<String> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::native::hasher::{hash_file, hash_array};
|
use crate::native::hasher::{hash_array, hash_file};
|
||||||
use assert_fs::prelude::*;
|
use assert_fs::prelude::*;
|
||||||
use assert_fs::TempDir;
|
use assert_fs::TempDir;
|
||||||
|
|
||||||
|
|||||||
@ -8,4 +8,3 @@ use crate::native::project_graph::types::ProjectGraph;
|
|||||||
pub fn transfer_project_graph(project_graph: ProjectGraph) -> External<ProjectGraph> {
|
pub fn transfer_project_graph(project_graph: ProjectGraph) -> External<ProjectGraph> {
|
||||||
External::new(project_graph)
|
External::new(project_graph)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,14 +32,8 @@ impl RustPseudoTerminal {
|
|||||||
quiet: Option<bool>,
|
quiet: Option<bool>,
|
||||||
tty: Option<bool>,
|
tty: Option<bool>,
|
||||||
) -> napi::Result<ChildProcess> {
|
) -> napi::Result<ChildProcess> {
|
||||||
self.pseudo_terminal.run_command(
|
self.pseudo_terminal
|
||||||
command,
|
.run_command(command, command_dir, js_env, exec_argv, quiet, tty)
|
||||||
command_dir,
|
|
||||||
js_env,
|
|
||||||
exec_argv,
|
|
||||||
quiet,
|
|
||||||
tty,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This allows us to run a pseudoterminal with a fake node ipc channel
|
/// This allows us to run a pseudoterminal with a fake node ipc channel
|
||||||
|
|||||||
@ -33,14 +33,8 @@ impl RustPseudoTerminal {
|
|||||||
quiet: Option<bool>,
|
quiet: Option<bool>,
|
||||||
tty: Option<bool>,
|
tty: Option<bool>,
|
||||||
) -> napi::Result<ChildProcess> {
|
) -> napi::Result<ChildProcess> {
|
||||||
self.pseudo_terminal.run_command(
|
self.pseudo_terminal
|
||||||
command,
|
.run_command(command, command_dir, js_env, exec_argv, quiet, tty)
|
||||||
command_dir,
|
|
||||||
js_env,
|
|
||||||
exec_argv,
|
|
||||||
quiet,
|
|
||||||
tty,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This allows us to run a pseudoterminal with a fake node ipc channel
|
/// This allows us to run a pseudoterminal with a fake node ipc channel
|
||||||
|
|||||||
@ -117,7 +117,9 @@ impl PseudoTerminal {
|
|||||||
|
|
||||||
let mut content = String::from_utf8_lossy(&buf[0..len]).to_string();
|
let mut content = String::from_utf8_lossy(&buf[0..len]).to_string();
|
||||||
if content.contains("\x1B[6n") {
|
if content.contains("\x1B[6n") {
|
||||||
trace!("Prevented terminal escape sequence ESC[6n from being printed.");
|
trace!(
|
||||||
|
"Prevented terminal escape sequence ESC[6n from being printed."
|
||||||
|
);
|
||||||
content = content.replace("\x1B[6n", "");
|
content = content.replace("\x1B[6n", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,8 +4,8 @@ mod hash_project_config;
|
|||||||
mod hash_project_files;
|
mod hash_project_files;
|
||||||
mod hash_runtime;
|
mod hash_runtime;
|
||||||
mod hash_task_output;
|
mod hash_task_output;
|
||||||
mod hash_workspace_files;
|
|
||||||
mod hash_tsconfig;
|
mod hash_tsconfig;
|
||||||
|
mod hash_workspace_files;
|
||||||
|
|
||||||
pub use hash_env::*;
|
pub use hash_env::*;
|
||||||
pub use hash_external::*;
|
pub use hash_external::*;
|
||||||
@ -13,5 +13,5 @@ pub use hash_project_config::*;
|
|||||||
pub use hash_project_files::*;
|
pub use hash_project_files::*;
|
||||||
pub use hash_runtime::*;
|
pub use hash_runtime::*;
|
||||||
pub use hash_task_output::*;
|
pub use hash_task_output::*;
|
||||||
|
pub use hash_tsconfig::*;
|
||||||
pub use hash_workspace_files::*;
|
pub use hash_workspace_files::*;
|
||||||
pub use hash_tsconfig::*;
|
|
||||||
@ -158,12 +158,15 @@ mod tests {
|
|||||||
let hash_result = hash_project_files(proj_name, proj_root, file_sets, &file_map).unwrap();
|
let hash_result = hash_project_files(proj_name, proj_root, file_sets, &file_map).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
hash_result,
|
hash_result,
|
||||||
hash(&[
|
hash(
|
||||||
file_data1.hash.as_bytes(),
|
&[
|
||||||
file_data1.file.as_bytes(),
|
file_data1.hash.as_bytes(),
|
||||||
file_data3.hash.as_bytes(),
|
file_data1.file.as_bytes(),
|
||||||
file_data3.file.as_bytes()
|
file_data3.hash.as_bytes(),
|
||||||
].concat())
|
file_data3.file.as_bytes()
|
||||||
|
]
|
||||||
|
.concat()
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,12 +208,15 @@ mod tests {
|
|||||||
let hash_result = hash_project_files(proj_name, proj_root, file_sets, &file_map).unwrap();
|
let hash_result = hash_project_files(proj_name, proj_root, file_sets, &file_map).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
hash_result,
|
hash_result,
|
||||||
hash(&[
|
hash(
|
||||||
file_data1.hash.as_bytes(),
|
&[
|
||||||
file_data1.file.as_bytes(),
|
file_data1.hash.as_bytes(),
|
||||||
file_data3.hash.as_bytes(),
|
file_data1.file.as_bytes(),
|
||||||
file_data3.file.as_bytes(),
|
file_data3.hash.as_bytes(),
|
||||||
].concat())
|
file_data3.file.as_bytes(),
|
||||||
|
]
|
||||||
|
.concat()
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
use std::path::Path;
|
|
||||||
use crate::native::cache::expand_outputs::get_files_for_outputs;
|
use crate::native::cache::expand_outputs::get_files_for_outputs;
|
||||||
use crate::native::glob::build_glob_set;
|
use crate::native::glob::build_glob_set;
|
||||||
use crate::native::hasher::{hash_array, hash_file};
|
use crate::native::hasher::{hash_array, hash_file};
|
||||||
use anyhow::*;
|
use anyhow::*;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
use std::path::Path;
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
|
|
||||||
pub fn hash_task_output(workspace_root: &str, glob: &str, outputs: &[String]) -> Result<String> {
|
pub fn hash_task_output(workspace_root: &str, glob: &str, outputs: &[String]) -> Result<String> {
|
||||||
@ -14,7 +14,15 @@ pub fn hash_task_output(workspace_root: &str, glob: &str, outputs: &[String]) ->
|
|||||||
let hashes = output_files
|
let hashes = output_files
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
.filter(|file| glob.is_match(file))
|
.filter(|file| glob.is_match(file))
|
||||||
.filter_map(|file| hash_file(Path::new(workspace_root).join(file).to_str().expect("path contains invalid utf-8").to_owned()))
|
.filter_map(|file| {
|
||||||
|
hash_file(
|
||||||
|
Path::new(workspace_root)
|
||||||
|
.join(file)
|
||||||
|
.to_str()
|
||||||
|
.expect("path contains invalid utf-8")
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
Ok(hash_array(hashes.into_iter().map(Some).collect()))
|
Ok(hash_array(hashes.into_iter().map(Some).collect()))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,6 @@ mod utils;
|
|||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
pub mod details;
|
pub mod details;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
pub mod task_history;
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
pub mod running_tasks_service;
|
pub mod running_tasks_service;
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
pub mod task_history;
|
||||||
|
|||||||
@ -99,10 +99,12 @@ impl CountdownPopup {
|
|||||||
|
|
||||||
pub fn render(&mut self, f: &mut Frame<'_>, area: Rect) {
|
pub fn render(&mut self, f: &mut Frame<'_>, area: Rect) {
|
||||||
// Add a safety check to prevent rendering outside buffer bounds (this can happen if the user resizes the window a lot before it stabilizes it seems)
|
// Add a safety check to prevent rendering outside buffer bounds (this can happen if the user resizes the window a lot before it stabilizes it seems)
|
||||||
if area.height == 0 || area.width == 0 ||
|
if area.height == 0
|
||||||
area.x >= f.area().width ||
|
|| area.width == 0
|
||||||
area.y >= f.area().height {
|
|| area.x >= f.area().width
|
||||||
return; // Area is out of bounds, don't try to render
|
|| area.y >= f.area().height
|
||||||
|
{
|
||||||
|
return; // Area is out of bounds, don't try to render
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure area is entirely within frame bounds
|
// Ensure area is entirely within frame bounds
|
||||||
@ -112,7 +114,7 @@ impl CountdownPopup {
|
|||||||
width: area.width.min(f.area().width.saturating_sub(area.x)),
|
width: area.width.min(f.area().width.saturating_sub(area.x)),
|
||||||
height: area.height.min(f.area().height.saturating_sub(area.y)),
|
height: area.height.min(f.area().height.saturating_sub(area.y)),
|
||||||
};
|
};
|
||||||
|
|
||||||
let popup_height = 9;
|
let popup_height = 9;
|
||||||
let popup_width = 70;
|
let popup_width = 70;
|
||||||
|
|
||||||
|
|||||||
@ -27,10 +27,12 @@ impl HelpText {
|
|||||||
|
|
||||||
pub fn render(&self, f: &mut Frame<'_>, area: Rect) {
|
pub fn render(&self, f: &mut Frame<'_>, area: Rect) {
|
||||||
// Add a safety check to prevent rendering outside buffer bounds (this can happen if the user resizes the window a lot before it stabilizes it seems)
|
// Add a safety check to prevent rendering outside buffer bounds (this can happen if the user resizes the window a lot before it stabilizes it seems)
|
||||||
if area.height == 0 || area.width == 0 ||
|
if area.height == 0
|
||||||
area.x >= f.area().width ||
|
|| area.width == 0
|
||||||
area.y >= f.area().height {
|
|| area.x >= f.area().width
|
||||||
return; // Area is out of bounds, don't try to render
|
|| area.y >= f.area().height
|
||||||
|
{
|
||||||
|
return; // Area is out of bounds, don't try to render
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure area is entirely within frame bounds
|
// Ensure area is entirely within frame bounds
|
||||||
|
|||||||
@ -195,7 +195,7 @@ impl LayoutManager {
|
|||||||
terminal_panes: Vec::new(),
|
terminal_panes: Vec::new(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.task_list_visibility {
|
match self.task_list_visibility {
|
||||||
TaskListVisibility::Hidden => self.calculate_layout_hidden_task_list(area),
|
TaskListVisibility::Hidden => self.calculate_layout_hidden_task_list(area),
|
||||||
TaskListVisibility::Visible => self.calculate_layout_visible_task_list(area),
|
TaskListVisibility::Visible => self.calculate_layout_visible_task_list(area),
|
||||||
@ -252,19 +252,15 @@ impl LayoutManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prevent divide-by-zero
|
// Prevent divide-by-zero
|
||||||
let task_list_height = if area.height < 3 {
|
let task_list_height = if area.height < 3 { 1 } else { area.height / 3 };
|
||||||
1
|
|
||||||
} else {
|
|
||||||
area.height / 3
|
|
||||||
};
|
|
||||||
|
|
||||||
// Apply padding only if there's enough space
|
// Apply padding only if there's enough space
|
||||||
let padding_height = if area.height > task_list_height + self.vertical_padding {
|
let padding_height = if area.height > task_list_height + self.vertical_padding {
|
||||||
self.vertical_padding
|
self.vertical_padding
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
// Ensure terminal pane has at least 1 row
|
// Ensure terminal pane has at least 1 row
|
||||||
let available_height = area.height.saturating_sub(task_list_height);
|
let available_height = area.height.saturating_sub(task_list_height);
|
||||||
let terminal_pane_height = available_height.saturating_sub(padding_height);
|
let terminal_pane_height = available_height.saturating_sub(padding_height);
|
||||||
@ -311,19 +307,15 @@ impl LayoutManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prevent divide-by-zero
|
// Prevent divide-by-zero
|
||||||
let task_list_width = if area.width < 3 {
|
let task_list_width = if area.width < 3 { 1 } else { area.width / 3 };
|
||||||
1
|
|
||||||
} else {
|
|
||||||
area.width / 3
|
|
||||||
};
|
|
||||||
|
|
||||||
// Apply padding only if there's enough space
|
// Apply padding only if there's enough space
|
||||||
let padding_width = if area.width > task_list_width + self.horizontal_padding {
|
let padding_width = if area.width > task_list_width + self.horizontal_padding {
|
||||||
self.horizontal_padding
|
self.horizontal_padding
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
// Ensure terminal pane has at least 1 column
|
// Ensure terminal pane has at least 1 column
|
||||||
let available_width = area.width.saturating_sub(task_list_width);
|
let available_width = area.width.saturating_sub(task_list_width);
|
||||||
let terminal_pane_width = available_width.saturating_sub(padding_width);
|
let terminal_pane_width = available_width.saturating_sub(padding_width);
|
||||||
@ -440,7 +432,10 @@ mod tests {
|
|||||||
fn test_default_properties() {
|
fn test_default_properties() {
|
||||||
let layout_manager = LayoutManager::new(5);
|
let layout_manager = LayoutManager::new(5);
|
||||||
assert_eq!(layout_manager.get_pane_arrangement(), PaneArrangement::None);
|
assert_eq!(layout_manager.get_pane_arrangement(), PaneArrangement::None);
|
||||||
assert_eq!(layout_manager.get_task_list_visibility(), TaskListVisibility::Visible);
|
assert_eq!(
|
||||||
|
layout_manager.get_task_list_visibility(),
|
||||||
|
TaskListVisibility::Visible
|
||||||
|
);
|
||||||
assert_eq!(layout_manager.get_task_count(), 5);
|
assert_eq!(layout_manager.get_task_count(), 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -689,43 +684,43 @@ mod tests {
|
|||||||
fn test_padding_between_components() {
|
fn test_padding_between_components() {
|
||||||
let mut layout_manager = LayoutManager::new(5);
|
let mut layout_manager = LayoutManager::new(5);
|
||||||
let area = create_test_area(100, 60);
|
let area = create_test_area(100, 60);
|
||||||
|
|
||||||
// Test with default horizontal padding (2)
|
// Test with default horizontal padding (2)
|
||||||
layout_manager.set_mode(LayoutMode::Horizontal);
|
layout_manager.set_mode(LayoutMode::Horizontal);
|
||||||
layout_manager.set_task_list_visibility(TaskListVisibility::Visible);
|
layout_manager.set_task_list_visibility(TaskListVisibility::Visible);
|
||||||
layout_manager.set_pane_arrangement(PaneArrangement::Single);
|
layout_manager.set_pane_arrangement(PaneArrangement::Single);
|
||||||
|
|
||||||
let layout = layout_manager.calculate_layout(area);
|
let layout = layout_manager.calculate_layout(area);
|
||||||
let task_list = layout.task_list.unwrap();
|
let task_list = layout.task_list.unwrap();
|
||||||
let terminal_pane = layout.terminal_panes[0];
|
let terminal_pane = layout.terminal_panes[0];
|
||||||
|
|
||||||
// The gap between task list and terminal pane should equal the horizontal padding
|
// The gap between task list and terminal pane should equal the horizontal padding
|
||||||
assert_eq!(terminal_pane.x - (task_list.x + task_list.width), 2);
|
assert_eq!(terminal_pane.x - (task_list.x + task_list.width), 2);
|
||||||
|
|
||||||
// Test with increased horizontal padding
|
// Test with increased horizontal padding
|
||||||
layout_manager.set_horizontal_padding(3);
|
layout_manager.set_horizontal_padding(3);
|
||||||
let layout = layout_manager.calculate_layout(area);
|
let layout = layout_manager.calculate_layout(area);
|
||||||
let task_list = layout.task_list.unwrap();
|
let task_list = layout.task_list.unwrap();
|
||||||
let terminal_pane = layout.terminal_panes[0];
|
let terminal_pane = layout.terminal_panes[0];
|
||||||
|
|
||||||
// The gap should now be 3
|
// The gap should now be 3
|
||||||
assert_eq!(terminal_pane.x - (task_list.x + task_list.width), 3);
|
assert_eq!(terminal_pane.x - (task_list.x + task_list.width), 3);
|
||||||
|
|
||||||
// Test with vertical layout and default vertical padding (1)
|
// Test with vertical layout and default vertical padding (1)
|
||||||
layout_manager.set_mode(LayoutMode::Vertical);
|
layout_manager.set_mode(LayoutMode::Vertical);
|
||||||
let layout = layout_manager.calculate_layout(area);
|
let layout = layout_manager.calculate_layout(area);
|
||||||
let task_list = layout.task_list.unwrap();
|
let task_list = layout.task_list.unwrap();
|
||||||
let terminal_pane = layout.terminal_panes[0];
|
let terminal_pane = layout.terminal_panes[0];
|
||||||
|
|
||||||
// The gap should be vertical and equal to the vertical padding
|
// The gap should be vertical and equal to the vertical padding
|
||||||
assert_eq!(terminal_pane.y - (task_list.y + task_list.height), 1);
|
assert_eq!(terminal_pane.y - (task_list.y + task_list.height), 1);
|
||||||
|
|
||||||
// Test with increased vertical padding
|
// Test with increased vertical padding
|
||||||
layout_manager.set_vertical_padding(2);
|
layout_manager.set_vertical_padding(2);
|
||||||
let layout = layout_manager.calculate_layout(area);
|
let layout = layout_manager.calculate_layout(area);
|
||||||
let task_list = layout.task_list.unwrap();
|
let task_list = layout.task_list.unwrap();
|
||||||
let terminal_pane = layout.terminal_panes[0];
|
let terminal_pane = layout.terminal_panes[0];
|
||||||
|
|
||||||
// The gap should now be 2
|
// The gap should now be 2
|
||||||
assert_eq!(terminal_pane.y - (task_list.y + task_list.height), 2);
|
assert_eq!(terminal_pane.y - (task_list.y + task_list.height), 2);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -297,7 +297,7 @@ impl<'a> StatefulWidget for TerminalPane<'a> {
|
|||||||
width: area.width.min(buf.area().width.saturating_sub(area.x)),
|
width: area.width.min(buf.area().width.saturating_sub(area.x)),
|
||||||
height: area.height.min(buf.area().height.saturating_sub(area.y)),
|
height: area.height.min(buf.area().height.saturating_sub(area.y)),
|
||||||
};
|
};
|
||||||
|
|
||||||
if safe_area.width > 0 && safe_area.height > 0 {
|
if safe_area.width > 0 && safe_area.height > 0 {
|
||||||
// Only attempt to render if we have a valid area
|
// Only attempt to render if we have a valid area
|
||||||
let text = "...";
|
let text = "...";
|
||||||
@ -308,7 +308,7 @@ impl<'a> StatefulWidget for TerminalPane<'a> {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the area doesn't extend beyond buffer boundaries
|
// Ensure the area doesn't extend beyond buffer boundaries
|
||||||
let safe_area = Rect {
|
let safe_area = Rect {
|
||||||
x: area.x,
|
x: area.x,
|
||||||
@ -316,7 +316,7 @@ impl<'a> StatefulWidget for TerminalPane<'a> {
|
|||||||
width: area.width.min(buf.area().width.saturating_sub(area.x)),
|
width: area.width.min(buf.area().width.saturating_sub(area.x)),
|
||||||
height: area.height.min(buf.area().height.saturating_sub(area.y)),
|
height: area.height.min(buf.area().height.saturating_sub(area.y)),
|
||||||
};
|
};
|
||||||
|
|
||||||
let base_style = self.get_base_style(state.task_status);
|
let base_style = self.get_base_style(state.task_status);
|
||||||
let border_style = if state.is_focused {
|
let border_style = if state.is_focused {
|
||||||
base_style
|
base_style
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use parking_lot::{Condvar, Mutex, MutexGuard};
|
|||||||
|
|
||||||
pub struct NxMutex<T>(Mutex<T>);
|
pub struct NxMutex<T>(Mutex<T>);
|
||||||
|
|
||||||
impl <T> NxMutex<T> {
|
impl<T> NxMutex<T> {
|
||||||
pub fn new(value: T) -> Self {
|
pub fn new(value: T) -> Self {
|
||||||
Self(Mutex::new(value))
|
Self(Mutex::new(value))
|
||||||
}
|
}
|
||||||
@ -18,9 +18,13 @@ impl NxCondvar {
|
|||||||
Self(Condvar::new())
|
Self(Condvar::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wait<'a, T, F>(&'a self, mut guard: MutexGuard<'a, T>, condition: F) -> anyhow::Result<MutexGuard<'a, T>>
|
pub fn wait<'a, T, F>(
|
||||||
where
|
&'a self,
|
||||||
F: Fn(&MutexGuard<'a, T>) -> bool
|
mut guard: MutexGuard<'a, T>,
|
||||||
|
condition: F,
|
||||||
|
) -> anyhow::Result<MutexGuard<'a, T>>
|
||||||
|
where
|
||||||
|
F: Fn(&MutexGuard<'a, T>) -> bool,
|
||||||
{
|
{
|
||||||
if condition(&guard) {
|
if condition(&guard) {
|
||||||
self.0.wait(&mut guard);
|
self.0.wait(&mut guard);
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use std::sync::{Condvar, LockResult, Mutex, MutexGuard};
|
|||||||
|
|
||||||
pub struct NxMutex<T>(Mutex<T>);
|
pub struct NxMutex<T>(Mutex<T>);
|
||||||
|
|
||||||
impl <T> NxMutex<T> {
|
impl<T> NxMutex<T> {
|
||||||
pub fn new(value: T) -> Self {
|
pub fn new(value: T) -> Self {
|
||||||
Self(Mutex::new(value))
|
Self(Mutex::new(value))
|
||||||
}
|
}
|
||||||
@ -18,9 +18,13 @@ impl NxCondvar {
|
|||||||
Self(Condvar::new())
|
Self(Condvar::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wait<'a, T, F>(&self, mutex_guard: MutexGuard<'a, T>, condition: F) -> LockResult<MutexGuard<'a, T>>
|
pub fn wait<'a, T, F>(
|
||||||
|
&self,
|
||||||
|
mutex_guard: MutexGuard<'a, T>,
|
||||||
|
condition: F,
|
||||||
|
) -> LockResult<MutexGuard<'a, T>>
|
||||||
where
|
where
|
||||||
F: Fn(&mut T) -> bool
|
F: Fn(&mut T) -> bool,
|
||||||
{
|
{
|
||||||
self.0.wait_while(mutex_guard, condition)
|
self.0.wait_while(mutex_guard, condition)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,4 +16,4 @@ pub fn is_ci() -> bool {
|
|||||||
|| env::var("BUILD_ID").is_ok()
|
|| env::var("BUILD_ID").is_ok()
|
||||||
|| env::var("BUILD_BUILDID").is_ok()
|
|| env::var("BUILD_BUILDID").is_ok()
|
||||||
|| env::var("TEAMCITY_VERSION").is_ok()
|
|| env::var("TEAMCITY_VERSION").is_ok()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use crate::native::{utils::normalize_trait::Normalize, types::FileData};
|
use crate::native::{types::FileData, utils::normalize_trait::Normalize};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
impl Normalize for Path {
|
impl Normalize for Path {
|
||||||
@ -65,13 +65,9 @@ mod test {
|
|||||||
FileData {
|
FileData {
|
||||||
file: "foo-other/not-child".into(),
|
file: "foo-other/not-child".into(),
|
||||||
hash: "123".into(),
|
hash: "123".into(),
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
let child_files = get_child_files(&directory, files);
|
let child_files = get_child_files(&directory, files);
|
||||||
assert_eq!(child_files, [
|
assert_eq!(child_files, ["foo/bar", "foo/baz", "foo/child/bar",]);
|
||||||
"foo/bar",
|
|
||||||
"foo/baz",
|
|
||||||
"foo/child/bar",
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,14 +50,13 @@ where
|
|||||||
!ignore_glob_set.is_match(path.as_ref())
|
!ignore_glob_set.is_match(path.as_ref())
|
||||||
})
|
})
|
||||||
.filter_map(move |entry| {
|
.filter_map(move |entry| {
|
||||||
entry
|
entry.ok().and_then(|e| {
|
||||||
.ok()
|
e.path()
|
||||||
.and_then(|e|
|
.strip_prefix(&base_dir)
|
||||||
e.path()
|
.ok()
|
||||||
.strip_prefix(&base_dir).ok()
|
|
||||||
.filter(|p| !p.to_string_lossy().is_empty())
|
.filter(|p| !p.to_string_lossy().is_empty())
|
||||||
.map(|p| p.to_owned())
|
.map(|p| p.to_owned())
|
||||||
)
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -61,7 +61,11 @@ fn hash_files(files: Vec<NxFile>) -> Vec<(String, NxFileHashed)> {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
} else {
|
} else {
|
||||||
trace!("hashing workspace files in {} chunks of {}", num_parallelism, chunks);
|
trace!(
|
||||||
|
"hashing workspace files in {} chunks of {}",
|
||||||
|
num_parallelism,
|
||||||
|
chunks
|
||||||
|
);
|
||||||
files
|
files
|
||||||
.par_chunks(chunks)
|
.par_chunks(chunks)
|
||||||
.flat_map_iter(|chunks| {
|
.flat_map_iter(|chunks| {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user