Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve goto_file_impl #9065

Merged
merged 23 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
eab5cbd
adding `shellexpand` and extend `surround_chars`
TornaxO7 Dec 12, 2023
0fdbc66
goto-file-path: adding test with ending character
TornaxO7 Dec 12, 2023
5f83d91
reformat code
TornaxO7 Dec 12, 2023
df34a6a
improving char collection for path
TornaxO7 Dec 13, 2023
264cd2b
add heuristic if cursor is on invalid char
TornaxO7 Dec 13, 2023
a88c86d
fix test
TornaxO7 Dec 13, 2023
1753c69
make clippy happy
TornaxO7 Dec 13, 2023
0da3262
removing `,` from the accepted file paths
TornaxO7 Dec 13, 2023
014a152
goto-file: improve head and tail detection
TornaxO7 Jan 11, 2024
63218c3
goto-file: remove one nesting
TornaxO7 Jan 11, 2024
1b9f5c4
goto-file: fix ci
TornaxO7 Jan 11, 2024
583d9aa
improve code format
TornaxO7 Feb 24, 2024
9bbccc5
Merge branch 'master' into feat/extend-goto-file
TornaxO7 Feb 24, 2024
f8063bb
removing `shellexpand` dependency
TornaxO7 Feb 24, 2024
7fbcbc0
reducing nested blocks
TornaxO7 Feb 24, 2024
b7bd427
removing unecessary clone
TornaxO7 Feb 24, 2024
a5cd316
allow numeric-values in path for goto-file
TornaxO7 Feb 24, 2024
c5c4c3e
add test to allow numeric values in filename for goto-file
TornaxO7 Feb 24, 2024
893c590
Merge branch 'master' of github.com:helix-editor/helix into feat/exte…
TornaxO7 Feb 27, 2024
6cce366
use `cfg` attribute instead of macro
TornaxO7 Feb 27, 2024
51dfd0a
removing saturating add
TornaxO7 Feb 27, 2024
de4fdbe
Merge branch 'master' of github.com:helix-editor/helix into feat/exte…
TornaxO7 Apr 6, 2024
366d792
goto-file: adjust valid chars
TornaxO7 Apr 6, 2024
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
Next Next commit
adding shellexpand and extend surround_chars
  • Loading branch information
TornaxO7 committed Dec 12, 2023
commit eab5cbd3ce7012949bab0567ae63f5926ff1d995
59 changes: 59 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion helix-term/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ serde = { version = "1.0", features = ["derive"] }
grep-regex = "0.1.12"
grep-searcher = "0.1.13"

[target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100
# expand env-variables in paths
shellexpand = "3.1"

[target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100
signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
libc = "0.2.150"

Expand Down
22 changes: 14 additions & 8 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,8 @@ fn goto_file_impl(cx: &mut Context, action: Action) {
let primary = selections.primary();
// Checks whether there is only one selection with a width of 1
if selections.len() == 1 && primary.len() == 1 {
paths.clear();

let count = cx.count();
let text_slice = text.slice(..);
// In this case it selects the WORD under the cursor
Expand All @@ -1187,14 +1189,18 @@ fn goto_file_impl(cx: &mut Context, action: Action) {
true,
);
// Trims some surrounding chars so that the actual file is opened.
let surrounding_chars: &[_] = &['\'', '"', '(', ')'];
paths.clear();
paths.push(
current_word
.fragment(text_slice)
.trim_matches(surrounding_chars)
.to_string(),
);
let surrounding_chars: &[_] = &['\'', '"', '(', ')', ',', ';', '{', '}', '[', ']'];
let path = current_word
.fragment(text_slice)
.trim_matches(surrounding_chars)
.to_string();

match shellexpand::full(&path) {
TornaxO7 marked this conversation as resolved.
Show resolved Hide resolved
Ok(path) => paths.push(path.to_string()),
Err(e) => {
cx.editor.set_error(format!("{}", e));
}
}
}

for sel in paths {
Expand Down
Loading