Skip to content

Commit 2e27d31

Browse files
committed
Merge branch 'main' of github.com:rust-mcp-stack/rust-mcp-filesystem into fix/issue-36-tool-box-macro-panic
2 parents af1bd53 + 1f7b985 commit 2e27d31

File tree

9 files changed

+114
-38
lines changed

9 files changed

+114
-38
lines changed

.release-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.2.1"
2+
".": "0.2.2"
33
}

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [0.2.2](https://github.com/rust-mcp-stack/rust-mcp-filesystem/compare/v0.2.1...v0.2.2) (2025-07-05)
4+
5+
6+
### 🐛 Bug Fixes
7+
8+
* Homebrew build issue ([da85e41](https://github.com/rust-mcp-stack/rust-mcp-filesystem/commit/da85e4122ca67219d80d5b2946004bbc7986cef9))
9+
310
## [0.2.1](https://github.com/rust-mcp-stack/rust-mcp-filesystem/compare/v0.2.0...v0.2.1) (2025-07-05)
411

512

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rust-mcp-filesystem"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
edition = "2021"
55
repository = "https://github.com/rust-mcp-stack/rust-mcp-filesystem"
66
authors = ["Ali Hashemi"]

docs/_coverpage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<!-- x-release-please-start-version -->
88

9-
# Rust MCP FileSystem (v0.2.1)
9+
# Rust MCP FileSystem (v0.2.2)
1010

1111
<!-- x-release-please-end -->
1212

docs/guide/install.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<!-- x-release-please-start-version -->
88

99
```sh
10-
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-installer.sh | sh
10+
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-installer.sh | sh
1111
```
1212

1313
#### **PowerShell script**
1414

1515
```sh
16-
powershell -ExecutionPolicy Bypass -c "irm https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-installer.ps1 | iex"
16+
powershell -ExecutionPolicy Bypass -c "irm https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-installer.ps1 | iex"
1717
```
1818

1919
<!-- x-release-please-end -->
@@ -38,78 +38,78 @@ brew install rust-mcp-stack/tap/rust-mcp-filesystem
3838
<tr>
3939
<td>
4040
<!-- x-release-please-start-version -->
41-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-aarch64-apple-darwin.tar.gz">rust-mcp-filesystem-aarch64-apple-darwin.tar.gz</a>
41+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-aarch64-apple-darwin.tar.gz">rust-mcp-filesystem-aarch64-apple-darwin.tar.gz</a>
4242
<!-- x-release-please-end -->
4343
</td>
4444
<td>Apple Silicon macOS</td>
4545
<td>
4646
<!-- x-release-please-start-version -->
47-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-aarch64-apple-darwin.tar.gz.sha256">checksum</a>
47+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-aarch64-apple-darwin.tar.gz.sha256">checksum</a>
4848
<!-- x-release-please-end -->
4949
</td>
5050
</tr>
5151
<tr>
5252
<td>
5353
<!-- x-release-please-start-version -->
54-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-x86_64-apple-darwin.tar.gz">rust-mcp-filesystem-x86_64-apple-darwin.tar.gz</a>
54+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-x86_64-apple-darwin.tar.gz">rust-mcp-filesystem-x86_64-apple-darwin.tar.gz</a>
5555
<!-- x-release-please-end -->
5656
</td>
5757
<td>Intel macOS</td>
5858
<td>
5959
<!-- x-release-please-start-version -->
60-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-x86_64-apple-darwin.tar.gz.sha256">checksum</a>
60+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-x86_64-apple-darwin.tar.gz.sha256">checksum</a>
6161
<!-- x-release-please-end -->
6262
</td>
6363
</tr>
6464
<tr>
6565
<td>
6666
<!-- x-release-please-start-version -->
67-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-x86_64-pc-windows-msvc.zip">rust-mcp-filesystem-x86_64-pc-windows-msvc.zip</a>
67+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-x86_64-pc-windows-msvc.zip">rust-mcp-filesystem-x86_64-pc-windows-msvc.zip</a>
6868
<!-- x-release-please-end -->
6969
</td>
7070
<td>x64 Windows (zip)</td>
7171
<td>
7272
<!-- x-release-please-start-version -->
73-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-x86_64-pc-windows-msvc.zip.sha256">checksum</a>
73+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-x86_64-pc-windows-msvc.zip.sha256">checksum</a>
7474
<!-- x-release-please-end -->
7575
</td>
7676
</tr>
7777
<tr>
7878
<td>
7979
<!-- x-release-please-start-version -->
80-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-x86_64-pc-windows-msvc.msi">rust-mcp-filesystem-x86_64-pc-windows-msvc.msi</a>
80+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-x86_64-pc-windows-msvc.msi">rust-mcp-filesystem-x86_64-pc-windows-msvc.msi</a>
8181
<!-- x-release-please-end -->
8282
</td>
8383
<td>x64 Windows (msi)</td>
8484
<td>
8585
<!-- x-release-please-start-version -->
86-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-x86_64-pc-windows-msvc.msi.sha256">checksum</a>
86+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-x86_64-pc-windows-msvc.msi.sha256">checksum</a>
8787
<!-- x-release-please-end -->
8888
</td>
8989
</tr>
9090
<tr>
9191
<td>
9292
<!-- x-release-please-start-version -->
93-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-aarch64-unknown-linux-gnu.tar.gz">rust-mcp-filesystem-aarch64-unknown-linux-gnu.tar.gz</a>
93+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-aarch64-unknown-linux-gnu.tar.gz">rust-mcp-filesystem-aarch64-unknown-linux-gnu.tar.gz</a>
9494
<!-- x-release-please-end -->
9595
</td>
9696
<td>ARM64 Linux</td>
9797
<td>
9898
<!-- x-release-please-start-version -->
99-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-aarch64-unknown-linux-gnu.tar.gz.sha256">checksum</a>
99+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-aarch64-unknown-linux-gnu.tar.gz.sha256">checksum</a>
100100
<!-- x-release-please-end -->
101101
</td>
102102
</tr>
103103
<tr>
104104
<td>
105105
<!-- x-release-please-start-version -->
106-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-x86_64-unknown-linux-gnu.tar.gz">rust-mcp-filesystem-x86_64-unknown-linux-gnu.tar.gz</a>
106+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-x86_64-unknown-linux-gnu.tar.gz">rust-mcp-filesystem-x86_64-unknown-linux-gnu.tar.gz</a>
107107
<!-- x-release-please-end -->
108108
</td>
109109
<td>x64 Linux</td>
110110
<td>
111111
<!-- x-release-please-start-version -->
112-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-x86_64-unknown-linux-gnu.tar.gz.sha256">checksum</a>
112+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-x86_64-unknown-linux-gnu.tar.gz.sha256">checksum</a>
113113
<!-- x-release-please-end -->
114114
</td>
115115
</tr>

docs/quickstart.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<!-- x-release-please-start-version -->
88

99
```sh
10-
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-installer.sh | sh
10+
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-installer.sh | sh
1111
```
1212

1313
#### **PowerShell script**
1414

1515
```sh
16-
powershell -ExecutionPolicy Bypass -c "irm https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-installer.ps1 | iex"
16+
powershell -ExecutionPolicy Bypass -c "irm https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-installer.ps1 | iex"
1717
```
1818

1919
<!-- x-release-please-end -->
@@ -38,78 +38,78 @@ brew install rust-mcp-stack/tap/rust-mcp-filesystem
3838
<tr>
3939
<td>
4040
<!-- x-release-please-start-version -->
41-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-aarch64-apple-darwin.tar.gz">rust-mcp-filesystem-aarch64-apple-darwin.tar.gz</a>
41+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-aarch64-apple-darwin.tar.gz">rust-mcp-filesystem-aarch64-apple-darwin.tar.gz</a>
4242
<!-- x-release-please-end -->
4343
</td>
4444
<td>Apple Silicon macOS</td>
4545
<td>
4646
<!-- x-release-please-start-version -->
47-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-aarch64-apple-darwin.tar.gz.sha256">checksum</a>
47+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-aarch64-apple-darwin.tar.gz.sha256">checksum</a>
4848
<!-- x-release-please-end -->
4949
</td>
5050
</tr>
5151
<tr>
5252
<td>
5353
<!-- x-release-please-start-version -->
54-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-x86_64-apple-darwin.tar.gz">rust-mcp-filesystem-x86_64-apple-darwin.tar.gz</a>
54+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-x86_64-apple-darwin.tar.gz">rust-mcp-filesystem-x86_64-apple-darwin.tar.gz</a>
5555
<!-- x-release-please-end -->
5656
</td>
5757
<td>Intel macOS</td>
5858
<td>
5959
<!-- x-release-please-start-version -->
60-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-x86_64-apple-darwin.tar.gz.sha256">checksum</a>
60+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-x86_64-apple-darwin.tar.gz.sha256">checksum</a>
6161
<!-- x-release-please-end -->
6262
</td>
6363
</tr>
6464
<tr>
6565
<td>
6666
<!-- x-release-please-start-version -->
67-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-x86_64-pc-windows-msvc.zip">rust-mcp-filesystem-x86_64-pc-windows-msvc.zip</a>
67+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-x86_64-pc-windows-msvc.zip">rust-mcp-filesystem-x86_64-pc-windows-msvc.zip</a>
6868
<!-- x-release-please-end -->
6969
</td>
7070
<td>x64 Windows (zip)</td>
7171
<td>
7272
<!-- x-release-please-start-version -->
73-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-x86_64-pc-windows-msvc.zip.sha256">checksum</a>
73+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-x86_64-pc-windows-msvc.zip.sha256">checksum</a>
7474
<!-- x-release-please-end -->
7575
</td>
7676
</tr>
7777
<tr>
7878
<td>
7979
<!-- x-release-please-start-version -->
80-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-x86_64-pc-windows-msvc.msi">rust-mcp-filesystem-x86_64-pc-windows-msvc.msi</a>
80+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-x86_64-pc-windows-msvc.msi">rust-mcp-filesystem-x86_64-pc-windows-msvc.msi</a>
8181
<!-- x-release-please-end -->
8282
</td>
8383
<td>x64 Windows (msi)</td>
8484
<td>
8585
<!-- x-release-please-start-version -->
86-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-x86_64-pc-windows-msvc.msi.sha256">checksum</a>
86+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-x86_64-pc-windows-msvc.msi.sha256">checksum</a>
8787
<!-- x-release-please-end -->
8888
</td>
8989
</tr>
9090
<tr>
9191
<td>
9292
<!-- x-release-please-start-version -->
93-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-aarch64-unknown-linux-gnu.tar.gz">rust-mcp-filesystem-aarch64-unknown-linux-gnu.tar.gz</a>
93+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-aarch64-unknown-linux-gnu.tar.gz">rust-mcp-filesystem-aarch64-unknown-linux-gnu.tar.gz</a>
9494
<!-- x-release-please-end -->
9595
</td>
9696
<td>ARM64 Linux</td>
9797
<td>
9898
<!-- x-release-please-start-version -->
99-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-aarch64-unknown-linux-gnu.tar.gz.sha256">checksum</a>
99+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-aarch64-unknown-linux-gnu.tar.gz.sha256">checksum</a>
100100
<!-- x-release-please-end -->
101101
</td>
102102
</tr>
103103
<tr>
104104
<td>
105105
<!-- x-release-please-start-version -->
106-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-x86_64-unknown-linux-gnu.tar.gz">rust-mcp-filesystem-x86_64-unknown-linux-gnu.tar.gz</a>
106+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-x86_64-unknown-linux-gnu.tar.gz">rust-mcp-filesystem-x86_64-unknown-linux-gnu.tar.gz</a>
107107
<!-- x-release-please-end -->
108108
</td>
109109
<td>x64 Linux</td>
110110
<td>
111111
<!-- x-release-please-start-version -->
112-
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.1/rust-mcp-filesystem-x86_64-unknown-linux-gnu.tar.gz.sha256">checksum</a>
112+
<a href="https://github.com/rust-mcp-stack/rust-mcp-filesystem/releases/download/v0.2.2/rust-mcp-filesystem-x86_64-unknown-linux-gnu.tar.gz.sha256">checksum</a>
113113
<!-- x-release-please-end -->
114114
</td>
115115
</tr>

src/fs_service.rs

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -862,24 +862,61 @@ impl FileSystemService {
862862
let max_length = max_length.unwrap_or(SNIPPET_MAX_LENGTH);
863863
let backward_chars = backward_chars.unwrap_or(SNIPPET_BACKWARD_CHARS);
864864

865+
// Calculate the number of leading whitespace bytes to adjust for trimmed input
865866
let start_pos = line.len() - line.trim_start().len();
866-
867+
// Trim leading and trailing whitespace from the input line
867868
let line = line.trim();
868869

869-
// Start SNIPPET_BACKWARD_CHARS characters before match (or at 0)
870-
let snippet_start = (match_result.start() - start_pos).saturating_sub(backward_chars);
870+
// Calculate the desired start byte index by adjusting match start for trimming and backward chars
871+
// match_result.start() is the byte index in the original string
872+
// Subtract start_pos to account for trimmed whitespace and backward_chars to include context before the match
873+
let desired_start = (match_result.start() - start_pos).saturating_sub(backward_chars);
874+
875+
// Find the nearest valid UTF-8 character boundary at or after desired_start
876+
// Prevents "byte index is not a char boundary" panic by ensuring the slice starts at a valid character (issue #37)
877+
let snippet_start = line
878+
.char_indices()
879+
.map(|(i, _)| i)
880+
.find(|&i| i >= desired_start)
881+
.unwrap_or(desired_start.min(line.len()));
882+
// Initialize a counter for tracking characters to respect max_length
883+
let mut char_count = 0;
884+
885+
// Calculate the desired end byte index by counting max_length characters from snippet_start
886+
// Take max_length + 1 to find the boundary after the last desired character
887+
let desired_end = line[snippet_start..]
888+
.char_indices()
889+
.take(max_length + 1)
890+
.find(|&(_, _)| {
891+
char_count += 1;
892+
char_count > max_length
893+
})
894+
.map(|(i, _)| snippet_start + i)
895+
.unwrap_or(line.len());
896+
897+
// Ensure snippet_end is a valid UTF-8 character boundary at or after desired_end
898+
// This prevents slicing issues with multi-byte characters
899+
let snippet_end = line
900+
.char_indices()
901+
.map(|(i, _)| i)
902+
.find(|&i| i >= desired_end)
903+
.unwrap_or(line.len());
871904

872-
// Get up to SNIPPET_MAX_LENGTH characters from snippet_start
873-
let snippet_end = (snippet_start + max_length).min(line.len());
905+
// Cap snippet_end to avoid exceeding the string length
906+
let snippet_end = snippet_end.min(line.len());
874907

908+
// Extract the snippet from the trimmed line using the calculated byte indices
875909
let snippet = &line[snippet_start..snippet_end];
876910

877-
// Add ellipses if line was truncated
878911
let mut result = String::new();
912+
// Add leading ellipsis if the snippet doesn't start at the beginning of the trimmed line
879913
if snippet_start > 0 {
880914
result.push_str("...");
881915
}
916+
882917
result.push_str(snippet);
918+
919+
// Add trailing ellipsis if the snippet doesn't reach the end of the trimmed line
883920
if snippet_end < line.len() {
884921
result.push_str("...");
885922
}

tests/test_fs_service.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,3 +1095,35 @@ fn search_files_content() {
10951095
assert_eq!(results[0].matches.len(), 2);
10961096
assert_eq!(results[1].matches.len(), 2);
10971097
}
1098+
1099+
#[test]
1100+
fn test_extract_snippet_bug_37() {
1101+
let (_, service) = setup_service(vec!["dir_search".to_string()]);
1102+
1103+
// Input string : ’ starts spans 3 bytes: 0xE2 0x80 0x99.
1104+
let line = "If and when that happens, however, we will not be able to declare victory quite yet. Defeating the open conspiracy to deprive students of physical access to books will do little to counteract the more diffuse confluence of forces that are depriving students of their education with a curly apostrophe ’ followed by more text";
1105+
1106+
let curly_pos = line.find("’").unwrap();
1107+
1108+
println!("Curly apostrophe at byte: {curly_pos}"); //position: 301
1109+
1110+
// Simulate a match just after the curly apostrophe
1111+
let match_start = curly_pos + 3; // Start of "followed"
1112+
let match_end = match_start + 8; // End of "followed"
1113+
let match_result = Match::new(match_start, match_end);
1114+
1115+
// Parameters to make snippet_start in extract_snippet() function to land inside ’ (e.g., byte 302)
1116+
let backward_chars = match_start - (curly_pos + 1); // Land on second byte of ’
1117+
println!(
1118+
"match_start: {match_start}, match_end: {match_end}, backward_chars {backward_chars} "
1119+
);
1120+
1121+
let result = service.extract_snippet(
1122+
line,
1123+
match_result,
1124+
Some(5), // max_length
1125+
Some(backward_chars),
1126+
);
1127+
1128+
println!("Snippet: {result}");
1129+
}

0 commit comments

Comments
 (0)