Skip to content

Commit 7caf005

Browse files
committed
fix file completion
1 parent 3bba9e3 commit 7caf005

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/file.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@ pub fn list_all_file_items(path: &Path) -> Vec<String> {
2323
const MAX_LINE_LENGTH: usize = 600;
2424

2525
pub fn get_file_items(current_line: &str, root_folder: &str) -> Vec<(String, usize)> {
26-
if current_line.len() >= MAX_LINE_LENGTH {
26+
if current_line.len() > MAX_LINE_LENGTH {
2727
return Vec::new();
2828
}
2929

30+
let indices: Vec<usize> = current_line.char_indices().map(|(i, _)| i).collect();
3031
let mut file_items = Vec::new();
3132
for (j, _) in current_line.char_indices().filter(|&(_, ch)| ch == '/' || ch == '\\') {
32-
for i in 0..j {
33-
let p = &current_line[i..j];
33+
for &i in indices.iter() {
34+
if i > j {
35+
continue;
36+
}
37+
let p = &current_line[i..j+1];
3438

3539
for base in [root_folder, ""].iter().map(PathBuf::from) {
3640
let path = base.join(p);

0 commit comments

Comments
 (0)