mirror of
https://github.com/instructkr/claw-code.git
synced 2026-11-20 00:00:00 +08:00
style: apply rustfmt formatting
This commit is contained in:
1 parent
f4c375641a
commit
44ff1249fa
4 files changed
+26
-26
No files matched your search
@@ -319,7 +319,7 @@ fn apply_line_selector(
|
|||||||
|
|
||||||
// Check if it's a contiguous range
|
// Check if it's a contiguous range
|
||||||
let is_contiguous = (last - first + 1) == indices.len();
|
let is_contiguous = (last - first + 1) == indices.len();
|
||||||
|
|
||||||
if is_contiguous {
|
if is_contiguous {
|
||||||
(first, last + 1, None)
|
(first, last + 1, None)
|
||||||
} else {
|
} else {
|
||||||
@@ -1295,13 +1295,9 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.expect("write should succeed");
|
.expect("write should succeed");
|
||||||
|
|
||||||
let output = super::read_file_with_selector(
|
let output =
|
||||||
path.to_string_lossy().as_ref(),
|
super::read_file_with_selector(path.to_string_lossy().as_ref(), None, None, Some("2"))
|
||||||
None,
|
.expect("read with selector should succeed");
|
||||||
None,
|
|
||||||
Some("2"),
|
|
||||||
)
|
|
||||||
.expect("read with selector should succeed");
|
|
||||||
assert_eq!(output.file.content, "line2");
|
assert_eq!(output.file.content, "line2");
|
||||||
assert_eq!(output.file.start_line, 2);
|
assert_eq!(output.file.start_line, 2);
|
||||||
assert_eq!(output.file.num_lines, 1);
|
assert_eq!(output.file.num_lines, 1);
|
||||||
@@ -1379,13 +1375,9 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.expect("write should succeed");
|
.expect("write should succeed");
|
||||||
|
|
||||||
let output = super::read_file_with_selector(
|
let output =
|
||||||
path.to_string_lossy().as_ref(),
|
super::read_file_with_selector(path.to_string_lossy().as_ref(), None, None, None)
|
||||||
None,
|
.expect("read with selector should succeed");
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.expect("read with selector should succeed");
|
|
||||||
assert_eq!(output.file.content, "line1\nline2\nline3\nline4\nline5");
|
assert_eq!(output.file.content, "line1\nline2\nline3\nline4\nline5");
|
||||||
assert_eq!(output.file.start_line, 1);
|
assert_eq!(output.file.start_line, 1);
|
||||||
assert_eq!(output.file.num_lines, 5);
|
assert_eq!(output.file.num_lines, 5);
|
||||||
|
|||||||
@@ -88,10 +88,10 @@ pub use conversation::{
|
|||||||
};
|
};
|
||||||
pub use file_ops::{
|
pub use file_ops::{
|
||||||
edit_file, edit_file_in_workspace, glob_search, glob_search_in_workspace, grep_search,
|
edit_file, edit_file_in_workspace, glob_search, glob_search_in_workspace, grep_search,
|
||||||
grep_search_in_workspace, read_file, read_file_in_workspace, read_file_with_selector,
|
grep_search_in_workspace, read_file, read_file_in_workspace,
|
||||||
read_file_in_workspace_with_selector, write_file, write_file_in_workspace, EditFileOutput,
|
read_file_in_workspace_with_selector, read_file_with_selector, write_file,
|
||||||
GlobSearchOutput, GrepSearchInput, GrepSearchOutput, ReadFileOutput, StructuredPatchHunk,
|
write_file_in_workspace, EditFileOutput, GlobSearchOutput, GrepSearchInput, GrepSearchOutput,
|
||||||
TextFilePayload, WriteFileOutput,
|
ReadFileOutput, StructuredPatchHunk, TextFilePayload, WriteFileOutput,
|
||||||
};
|
};
|
||||||
pub use git_context::{GitCommitEntry, GitContext};
|
pub use git_context::{GitCommitEntry, GitContext};
|
||||||
pub use hooks::{
|
pub use hooks::{
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
/// - `:5-16,960-973` = multiple ranges
|
/// - `:5-16,960-973` = multiple ranges
|
||||||
/// - `:raw` = full verbatim
|
/// - `:raw` = full verbatim
|
||||||
/// - `:conflicts` = git merge conflicts only
|
/// - `:conflicts` = git merge conflicts only
|
||||||
|
|
||||||
use std::num::ParseIntError;
|
use std::num::ParseIntError;
|
||||||
|
|
||||||
/// Parsed line range specification.
|
/// Parsed line range specification.
|
||||||
@@ -36,12 +35,18 @@ pub struct LineRange {
|
|||||||
impl LineRange {
|
impl LineRange {
|
||||||
/// Create a new line range (1-indexed).
|
/// Create a new line range (1-indexed).
|
||||||
pub fn new(start_line: usize, end_line: usize) -> Self {
|
pub fn new(start_line: usize, end_line: usize) -> Self {
|
||||||
Self { start_line, end_line }
|
Self {
|
||||||
|
start_line,
|
||||||
|
end_line,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert to zero-indexed range for internal use.
|
/// Convert to zero-indexed range for internal use.
|
||||||
pub fn zero_indexed(&self) -> (usize, usize) {
|
pub fn zero_indexed(&self) -> (usize, usize) {
|
||||||
(self.start_line.saturating_sub(1), self.end_line.saturating_sub(1))
|
(
|
||||||
|
self.start_line.saturating_sub(1),
|
||||||
|
self.end_line.saturating_sub(1),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the number of lines in this range.
|
/// Get the number of lines in this range.
|
||||||
|
|||||||
@@ -2575,7 +2575,8 @@ fn run_read_file(input: ReadFileInput) -> Result<String, String> {
|
|||||||
input.limit,
|
input.limit,
|
||||||
input.selector.as_deref(),
|
input.selector.as_deref(),
|
||||||
&workspace,
|
&workspace,
|
||||||
).map_err(io_to_string)?,
|
)
|
||||||
|
.map_err(io_to_string)?,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10704,8 +10705,7 @@ printf 'pwsh:%s' "$1"
|
|||||||
let root = temp_path("perm-read-selector");
|
let root = temp_path("perm-read-selector");
|
||||||
fs::create_dir_all(&root).expect("create root");
|
fs::create_dir_all(&root).expect("create root");
|
||||||
let file = root.join("multi-line.txt");
|
let file = root.join("multi-line.txt");
|
||||||
fs::write(&file, "line1\nline2\nline3\nline4\nline5\n")
|
fs::write(&file, "line1\nline2\nline3\nline4\nline5\n").expect("write test file");
|
||||||
.expect("write test file");
|
|
||||||
let original_dir = std::env::current_dir().expect("cwd");
|
let original_dir = std::env::current_dir().expect("cwd");
|
||||||
std::env::set_current_dir(&root).expect("set cwd");
|
std::env::set_current_dir(&root).expect("set cwd");
|
||||||
|
|
||||||
@@ -10717,7 +10717,10 @@ printf 'pwsh:%s' "$1"
|
|||||||
"selector": "2-4"
|
"selector": "2-4"
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
assert!(result.is_ok(), "read_file with selector should succeed: {result:?}");
|
assert!(
|
||||||
|
result.is_ok(),
|
||||||
|
"read_file with selector should succeed: {result:?}"
|
||||||
|
);
|
||||||
|
|
||||||
// Verify the output contains the expected lines
|
// Verify the output contains the expected lines
|
||||||
let output: serde_json::Value =
|
let output: serde_json::Value =
|
||||||
|
|||||||
Reference in new issue
Block a user