Skip to content

Commit 165070b

Browse files
committed
Merge remote-tracking branch 'main/master' into resize-windows
2 parents 58210ae + 88bc52a commit 165070b

File tree

17 files changed

+345
-130
lines changed

17 files changed

+345
-130
lines changed

Cargo.lock

Lines changed: 30 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

book/src/generated/lang-support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155
| t32 || | | |
156156
| tablegen |||| |
157157
| task || | | |
158+
| templ || | | `templ` |
158159
| tfvars || || `terraform-ls` |
159160
| todotxt || | | |
160161
| toml || | | `taplo` |

helix-core/src/wrap.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use smartstring::{LazyCompact, SmartString};
2+
use textwrap::{Options, WordSplitter::NoHyphenation};
23

34
/// Given a slice of text, return the text re-wrapped to fit it
45
/// within the given width.
56
pub fn reflow_hard_wrap(text: &str, text_width: usize) -> SmartString<LazyCompact> {
6-
textwrap::refill(text, text_width).into()
7+
let options = Options::new(text_width).word_splitter(NoHyphenation);
8+
textwrap::refill(text, options).into()
79
}

helix-term/src/application.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ impl Application {
162162
// Unset path to prevent accidentally saving to the original tutor file.
163163
doc_mut!(editor).set_path(None);
164164
} else if !args.files.is_empty() {
165-
let first = &args.files[0].0; // we know it's not empty
166-
if first.is_dir() {
165+
if args.open_cwd {
167166
// NOTE: The working directory is already set to args.files[0] in main()
168167
editor.new_file(Action::VerticalSplit);
169168
let picker = ui::file_picker(".".into(), &config.load().editor);

helix-term/src/args.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub struct Args {
1717
pub log_file: Option<PathBuf>,
1818
pub config_file: Option<PathBuf>,
1919
pub files: Vec<(PathBuf, Position)>,
20+
pub open_cwd: bool,
2021
pub working_directory: Option<PathBuf>,
2122
}
2223

helix-term/src/commands.rs

Lines changed: 72 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,7 +2208,10 @@ fn global_search(cx: &mut Context) {
22082208
let searcher = SearcherBuilder::new()
22092209
.binary_detection(BinaryDetection::quit(b'\x00'))
22102210
.build();
2211-
WalkBuilder::new(search_root)
2211+
2212+
let mut walk_builder = WalkBuilder::new(search_root);
2213+
2214+
walk_builder
22122215
.hidden(file_picker_config.hidden)
22132216
.parents(file_picker_config.parents)
22142217
.ignore(file_picker_config.ignore)
@@ -2219,73 +2222,77 @@ fn global_search(cx: &mut Context) {
22192222
.max_depth(file_picker_config.max_depth)
22202223
.filter_entry(move |entry| {
22212224
filter_picker_entry(entry, &absolute_root, dedup_symlinks)
2222-
})
2223-
.build_parallel()
2224-
.run(|| {
2225-
let mut searcher = searcher.clone();
2226-
let matcher = matcher.clone();
2227-
let injector = injector_.clone();
2228-
let documents = &documents;
2229-
Box::new(move |entry: Result<DirEntry, ignore::Error>| -> WalkState {
2230-
let entry = match entry {
2231-
Ok(entry) => entry,
2232-
Err(_) => return WalkState::Continue,
2233-
};
2234-
2235-
match entry.file_type() {
2236-
Some(entry) if entry.is_file() => {}
2237-
// skip everything else
2238-
_ => return WalkState::Continue,
2239-
};
2240-
2241-
let mut stop = false;
2242-
let sink = sinks::UTF8(|line_num, _| {
2243-
stop = injector
2244-
.push(FileResult::new(entry.path(), line_num as usize - 1))
2245-
.is_err();
2246-
2247-
Ok(!stop)
2248-
});
2249-
let doc = documents.iter().find(|&(doc_path, _)| {
2250-
doc_path
2251-
.as_ref()
2252-
.map_or(false, |doc_path| doc_path == entry.path())
2253-
});
2254-
2255-
let result = if let Some((_, doc)) = doc {
2256-
// there is already a buffer for this file
2257-
// search the buffer instead of the file because it's faster
2258-
// and captures new edits without requiring a save
2259-
if searcher.multi_line_with_matcher(&matcher) {
2260-
// in this case a continous buffer is required
2261-
// convert the rope to a string
2262-
let text = doc.to_string();
2263-
searcher.search_slice(&matcher, text.as_bytes(), sink)
2264-
} else {
2265-
searcher.search_reader(
2266-
&matcher,
2267-
RopeReader::new(doc.slice(..)),
2268-
sink,
2269-
)
2270-
}
2271-
} else {
2272-
searcher.search_path(&matcher, entry.path(), sink)
2273-
};
2225+
});
22742226

2275-
if let Err(err) = result {
2276-
log::error!(
2277-
"Global search error: {}, {}",
2278-
entry.path().display(),
2279-
err
2280-
);
2281-
}
2282-
if stop {
2283-
WalkState::Quit
2227+
walk_builder
2228+
.add_custom_ignore_filename(helix_loader::config_dir().join("ignore"));
2229+
walk_builder.add_custom_ignore_filename(".helix/ignore");
2230+
2231+
walk_builder.build_parallel().run(|| {
2232+
let mut searcher = searcher.clone();
2233+
let matcher = matcher.clone();
2234+
let injector = injector_.clone();
2235+
let documents = &documents;
2236+
Box::new(move |entry: Result<DirEntry, ignore::Error>| -> WalkState {
2237+
let entry = match entry {
2238+
Ok(entry) => entry,
2239+
Err(_) => return WalkState::Continue,
2240+
};
2241+
2242+
match entry.file_type() {
2243+
Some(entry) if entry.is_file() => {}
2244+
// skip everything else
2245+
_ => return WalkState::Continue,
2246+
};
2247+
2248+
let mut stop = false;
2249+
let sink = sinks::UTF8(|line_num, _| {
2250+
stop = injector
2251+
.push(FileResult::new(entry.path(), line_num as usize - 1))
2252+
.is_err();
2253+
2254+
Ok(!stop)
2255+
});
2256+
let doc = documents.iter().find(|&(doc_path, _)| {
2257+
doc_path
2258+
.as_ref()
2259+
.map_or(false, |doc_path| doc_path == entry.path())
2260+
});
2261+
2262+
let result = if let Some((_, doc)) = doc {
2263+
// there is already a buffer for this file
2264+
// search the buffer instead of the file because it's faster
2265+
// and captures new edits without requiring a save
2266+
if searcher.multi_line_with_matcher(&matcher) {
2267+
// in this case a continous buffer is required
2268+
// convert the rope to a string
2269+
let text = doc.to_string();
2270+
searcher.search_slice(&matcher, text.as_bytes(), sink)
22842271
} else {
2285-
WalkState::Continue
2272+
searcher.search_reader(
2273+
&matcher,
2274+
RopeReader::new(doc.slice(..)),
2275+
sink,
2276+
)
22862277
}
2287-
})
2288-
});
2278+
} else {
2279+
searcher.search_path(&matcher, entry.path(), sink)
2280+
};
2281+
2282+
if let Err(err) = result {
2283+
log::error!(
2284+
"Global search error: {}, {}",
2285+
entry.path().display(),
2286+
err
2287+
);
2288+
}
2289+
if stop {
2290+
WalkState::Quit
2291+
} else {
2292+
WalkState::Continue
2293+
}
2294+
})
2295+
});
22892296
});
22902297

22912298
cx.jobs.callback(async move {

0 commit comments

Comments
 (0)