Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fs_service/io/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl FileSystemService {
let start_pos = if line_count <= n {
0 // Read from start if fewer than n lines
} else {
*newline_positions.get(line_count - n).unwrap_or(&0) + 1
*newline_positions.get(n-1).unwrap_or(&0) + 1
};

// Read forward from start_pos
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tail_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::fs_service::FileSystemService;
pub struct TailFile {
/// The path of the file to get information for.
pub path: String,
/// The number of lines to read from the beginning of the file.
/// The number of lines to read from the ending of the file.
Copy link
Copy Markdown
Member

@hashemix hashemix Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a valid change, thanks πŸ‘

pub lines: u64,
}

Expand Down
4 changes: 2 additions & 2 deletions tests/test_fs_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1213,13 +1213,13 @@ async fn test_tail_file_normal() {
let file_path = create_test_file_with_line_ending(
&temp_dir.to_path_buf(),
"dir1/test.txt",
vec!["line1", "line2", "line3", "line4", "line5"],
vec!["line1", "line2", "line3", "line4", "line5", "line6"],
"\n",
)
.await;

let result = service.tail_file(&file_path, 3).await.unwrap();
assert_eq!(result, "line3\nline4\nline5"); // No trailing newline
assert_eq!(result, "line4\nline5\nline6"); // No trailing newline
}

#[tokio::test]
Expand Down
Loading