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

File explorer and tree helper (v3) #5768

Open
wants to merge 118 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
b652f96
tree helper and file explorer
cossonleo Apr 3, 2022
d9d4daa
feat(ui/explore): implement "focus current file"
wongjiahau Feb 1, 2023
c446c39
feat(explorer/position): right
wongjiahau Feb 6, 2023
d04a1ce
refactor(tree): change internal implementation
wongjiahau Feb 11, 2023
aa397ef
feat(explore): reveal current file
wongjiahau Feb 12, 2023
bdab93e
feat(explore): search
wongjiahau Feb 12, 2023
82fe4a3
test(ui/tree): find
wongjiahau Feb 12, 2023
0f8b641
feat(tree): filter
wongjiahau Feb 12, 2023
458fa1c
feat(explore): add folder/file
wongjiahau Feb 13, 2023
2af8b41
feat(explore): remove files/folder
wongjiahau Feb 13, 2023
44b46dd
feat(explore): rename file/folder
wongjiahau Feb 13, 2023
5a5a1de
fix(explore/rename): should regenarate index
wongjiahau Feb 13, 2023
52a26ff
feat(explore): refresh
wongjiahau Feb 13, 2023
ec2059b
style(ui/tree): highlight ancestor
wongjiahau Feb 13, 2023
ddb7564
feat(explore): add help
wongjiahau Feb 13, 2023
2bafac0
feat(explore): go to previous root
wongjiahau Feb 13, 2023
35ffc60
feat(explore): increase/decrease explorer size
wongjiahau Feb 13, 2023
2c221f0
fix(explore): help page overflow
wongjiahau Feb 13, 2023
790192d
doc(explorer): up to date
wongjiahau Feb 13, 2023
b38a941
feat(explore): close without clearing previous state
wongjiahau Feb 13, 2023
56056e8
fix(explore): increase size will cause panic
wongjiahau Feb 14, 2023
a079477
fix(compile): warnings
wongjiahau Feb 14, 2023
85fa1c5
feat(explore):
wongjiahau Feb 14, 2023
9bd534b
fix(explore): filter
wongjiahau Feb 14, 2023
7249536
fix(explore): 'h' does not realign preview properly
wongjiahau Feb 14, 2023
94e2c29
fix(command): space e does not focus explorer when no files are opened
wongjiahau Feb 15, 2023
374b8dd
style(explore): make Right the default position
wongjiahau Feb 15, 2023
c8578ba
fix: warnings
wongjiahau Feb 15, 2023
30bac64
Revert "style(explore): make Right the default position"
wongjiahau Feb 15, 2023
ef73559
fix(explore): cannot focus explorer if no opened document
wongjiahau Feb 15, 2023
0f8e0a5
fix(tree): deleting last file causes panic
wongjiahau Feb 15, 2023
70984fd
Merge branch 'master' of https://github.com/helix-editor/helix into r…
wongjiahau Feb 15, 2023
f0a4b10
Merge branch 'refactor-tree-explorer' of github.com:pinelang/helix-tr…
wongjiahau Feb 15, 2023
4dfa869
style(tree): increase indentation
wongjiahau Feb 16, 2023
c88164f
feat(tree-view): add unit tests
wongjiahau Feb 16, 2023
64059fb
feat(tree): move left/right
wongjiahau Feb 19, 2023
2a60662
feat(explore): add focus indicator
wongjiahau Feb 20, 2023
2e654a0
refactor(explore): move search function to Tree
wongjiahau Feb 20, 2023
2e7709e
MULTI
wongjiahau Feb 21, 2023
a259c20
fix(explore): help overflow
wongjiahau Feb 22, 2023
bcb1672
fix(explore):
wongjiahau Feb 22, 2023
78bb297
Merge branch 'master' of https://github.com/helix-editor/helix into a…
wongjiahau Feb 22, 2023
6321dc9
chore: rename explore to explorer
wongjiahau Feb 22, 2023
7b63fda
test(explorer): add integration tests
wongjiahau Feb 23, 2023
f9ff01d
chore(ui/tree): bind 'o' to Toggle
wongjiahau Feb 23, 2023
899491b
feat(tree): add C-n/C-p keybinding
wongjiahau Feb 23, 2023
6af9a06
feat(explorer): bind "="/"_" to "Zoom in"/"Zoom out"
wongjiahau Feb 23, 2023
9205117
fix: failing tests
wongjiahau Feb 23, 2023
cf9b60a
feat(tree): sticky ancestors
wongjiahau Feb 25, 2023
dffbc15
refactor(explorer,tree): remove unwrap to avoid panics
wongjiahau Feb 25, 2023
36769cb
fix(explorer/keymap): change 'b' to 'B'
wongjiahau Feb 25, 2023
b5d92ac
chore: fix clippy warnings
wongjiahau Feb 25, 2023
38ef079
feat(tree): jump forward
wongjiahau Feb 25, 2023
24b50bb
feat(explorer): toggle preview
wongjiahau Feb 25, 2023
72b845d
Merge branch 'master' of https://github.com/helix-editor/helix into t…
wongjiahau Feb 25, 2023
ba00a80
fix(tree): shouldn't use patched font
wongjiahau Feb 25, 2023
601f2c4
chore(ui/tree): remove useless comments
wongjiahau Feb 25, 2023
ef18502
chore: remove temp file
wongjiahau Feb 25, 2023
5d600fe
doc(helix-term/.gitignore): document purpose of test-explorer
wongjiahau Feb 25, 2023
d578f8a
chore: fix clippy warning
wongjiahau Feb 26, 2023
c3b8be9
fix(ci): clippy + failure on Windows
wongjiahau Feb 26, 2023
c0073ed
Merge branch 'tree_explore' of github.com:pinelang/helix-tree-explore…
wongjiahau Feb 26, 2023
4a0c620
fix(explorer/filter): not working for newly opened folder
wongjiahau Feb 26, 2023
7e4feb0
fix(explore): search using previous search word after filter does not…
wongjiahau Feb 27, 2023
fae4990
test(tree): search prompt and filter prompt
wongjiahau Feb 28, 2023
8379669
Merge branch 'master' of https://github.com/helix-editor/helix into t…
wongjiahau Feb 28, 2023
b18a974
fix(explorer): go to previous root does not update state.current_root
wongjiahau Feb 28, 2023
19d436e
Merge branch 'master' of https://github.com/helix-editor/helix into t…
wongjiahau Mar 1, 2023
a2cb28d
chore(keymap): merge with the correct version
wongjiahau Mar 1, 2023
43b226a
feat(explorer/keymap): combine 'a' with 'A'
wongjiahau Mar 2, 2023
c2e2f05
feat(explorer/delete): no need to press Enter, just press y
wongjiahau Mar 2, 2023
a4943a7
fix(explorer/overlay): prompt overflow
wongjiahau Mar 2, 2023
8ef95ee
Merge branch 'master' of https://github.com/helix-editor/helix into t…
wongjiahau Mar 6, 2023
d3db1b6
style(tree): improve ancestor contrast
wongjiahau Mar 6, 2023
31c0e84
fix(ci): failing windows test & clippy
wongjiahau Mar 6, 2023
bc62b76
fix(ci): failing windows test & clippy
wongjiahau Mar 6, 2023
aa6780e
feat(ui/tree): tree-based movements
wongjiahau Mar 7, 2023
80a2f86
Merge branch 'tree_explore' of github.com:pinelang/helix-tree-explore…
wongjiahau Mar 7, 2023
d62b487
feat(ui/tree): undo breaking changes
wongjiahau Mar 7, 2023
d1e6a21
Merge branch 'master' of https://github.com/helix-editor/helix into t…
wongjiahau Mar 7, 2023
e991ed9
refactor(runtime/themes): revert changes to theme files
wongjiahau Mar 7, 2023
9726ae7
fix(ci/test): failing on Windows
wongjiahau Mar 7, 2023
7ccee10
chore: correction of e991ed9
wongjiahau Mar 7, 2023
10032eb
fix(ci): cargo fmt
wongjiahau Mar 8, 2023
d043ea4
Merge branch 'master' of https://github.com/helix-editor/helix into t…
wongjiahau Mar 8, 2023
1108c88
Merge branch 'master' into tree_explore
wongjiahau Mar 9, 2023
eb9287d
fix(ci): cargo fmt and windows test
wongjiahau Mar 9, 2023
20241fb
Merge branch 'master' of https://github.com/helix-editor/helix into t…
wongjiahau Mar 13, 2023
54b1693
Merge branch 'master' of https://github.com/helix-editor/helix into t…
wongjiahau Mar 14, 2023
c4c3e80
style(explorer/delete): capitalize default choice
wongjiahau Mar 14, 2023
1780867
refactor(ui/explorer/handle_prompt_event): remove unnecessary function
wongjiahau Mar 14, 2023
9a1aff2
refactor(ui/explorer/close_documents): concise code
wongjiahau Mar 14, 2023
8b561e2
fix: type error
wongjiahau Mar 14, 2023
41ebc30
fix(ui/tree/clone): `is_openend` should not be false
wongjiahau Mar 14, 2023
52be2e0
refactor(ui/tree): remove filter
wongjiahau Mar 16, 2023
f5af209
refactor(explorer): remove preview
wongjiahau Mar 17, 2023
afda68a
chore: cargo fmt
wongjiahau Mar 17, 2023
e5dfde2
refactor(explorer): remove overlay option
wongjiahau Mar 17, 2023
1be2ac2
fix(ui/explorer): tree search cursor not rendered
wongjiahau Mar 18, 2023
ee34720
style(explorer): move title to statusline
wongjiahau Mar 18, 2023
404f950
fix(tests/explorer/new_folder): failing on Windows
wongjiahau Mar 22, 2023
898c167
fix(integration-test/test_goto_file_impl): failing due to untested ch…
wongjiahau Mar 22, 2023
33542e9
refactor: remove unnecessary dev-dependencies
wongjiahau Mar 22, 2023
f5aec54
chore(commands): revert accidental typo
wongjiahau Mar 22, 2023
a331e52
chore(keymap): remove "<space>E"
wongjiahau Mar 22, 2023
eebff62
chore(doc/configuration/explorer/position): remove `overlay` option
wongjiahau Mar 22, 2023
f37c795
chore(ui/prompt): use &str instead of Cow<str>
wongjiahau Mar 23, 2023
88ac941
Merge branch 'master' of https://github.com/helix-editor/helix into t…
wongjiahau Mar 25, 2023
cf9669f
fix(ci): clippy error
wongjiahau Mar 27, 2023
e2c3757
Merge branch 'master' of https://github.com/helix-editor/helix into t…
wongjiahau May 12, 2023
2d1ca23
refactor(explorer/tests): use tempfile instead
wongjiahau May 12, 2023
4fe9896
chore(book/src/configuration.md): remove accidental addition
wongjiahau May 12, 2023
d86abf1
chore(explorer): minor code changes
wongjiahau May 12, 2023
0885057
perf(tree/reveal-item): remove over-conservative refresh
wongjiahau May 16, 2023
99e3db4
Merge branch 'master' of https://github.com/helix-editor/helix into t…
wongjiahau Jun 16, 2023
10f302d
Merge branch 'master' of https://github.com/helix-editor/helix into t…
wongjiahau Jul 25, 2023
fd80660
Merge branch 'master' of https://github.com/helix-editor/helix into t…
wongjiahau Jul 31, 2023
2c27974
Merge branch 'master' of https://github.com/helix-editor/helix into t…
wongjiahau Aug 22, 2023
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
124 changes: 124 additions & 0 deletions Cargo.lock

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

10 changes: 10 additions & 0 deletions book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ auto-pairs = false # defaults to `true`
The default pairs are <code>(){}[]''""``</code>, but these can be customized by
setting `auto-pairs` to a TOML table:

Example

wongjiahau marked this conversation as resolved.
Show resolved Hide resolved
```toml
[editor.auto-pairs]
'(' = ')'
Expand Down Expand Up @@ -332,3 +334,11 @@ max-wrap = 25 # increase value to reduce forced mid-word wrapping
max-indent-retain = 0
wrap-indicator = "" # set wrap-indicator to "" to hide it
```

### `[editor.explorer]` Section
Sets explorer side width and style.

| Key | Description | Default |
| --- | ----------- | ------- |
| `column-width` | explorer side width | 30 |
| `position` | explorer widget position, `overlay`, `right`, or `left` | `left` |
wongjiahau marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 6 additions & 0 deletions book/src/keymap.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ This layer is a kludge of mappings, mostly pickers.
| `R` | Replace selections by clipboard contents | `replace_selections_with_clipboard` |
| `/` | Global search in workspace folder | `global_search` |
| `?` | Open command palette | `command_palette` |
| `e` | Open or focus explorer | `toggle_or_focus_explorer` |
| `E` | Reveal current file in explorer | `reveal_current_file` |

> TIP: Global search displays results in a fuzzy picker, use `Space + '` to bring it back up after opening a file.

Expand Down Expand Up @@ -440,3 +442,7 @@ Keys to use within prompt, Remapping currently not supported.
| `Tab` | Select next completion item |
| `BackTab` | Select previous completion item |
| `Enter` | Open selected |

# File explorer
Press `?` to see keymaps. Remapping currently not supported.

58 changes: 58 additions & 0 deletions changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
- [x] "h" moves to parent instead of scrolling to left
wongjiahau marked this conversation as resolved.
Show resolved Hide resolved
- [x] "l" steps into current folder instead of scrolling to right


TODO
- [x] make focus current file works
- [x] test all explorer functionality (e.g. "/" etc)
- [x] Go to parent directory
- [x] add help
- [x] highlight ancestors of current selection
- [x] search "N" will hang
- [x] implement rename
- [x] implement close (refer how overlay works)
- [x] implement refresh
- [x] bug: delete file collapsed whole tree
- [x] update documentation
- [x] fix list view
- [x] -/+ to increase or decrease width
- [x] help page overflow
- [x] preview not showing in small screen
- [x] fix (-/+) overflow
- [x] improve filter UI/UX (should only apply to child not parent)
- [x] bug: "h" does not realign preview
- [x] bug: reveal file does not realign preview
- [] "l" goes back to previous child if any history
- [x] Merge conflicts
- [x] Remove comments
- [x] fix warnings
- [x] refactor, add tree.expand_children() method

New:
- [x] increase indentation
- [x] Change '[' to "go to previous root"
- [x] Change 'B' to "go to parent"
- [x] Use C-o/C-i for jump backward/forward
- [x] on focus indication
- [x] support creating files and folder and the same time (`mkdir -p`)
- [x] Ctrl-o should work for 'h', 'gg', 'ge', etc
- [x] add unit test for TreeView
- [x] explorer(help): overflow
- [x] n/N wrap around
- [x] fix(filter): crash
- [x] fix(explorer/preview): panic if not tall enough
- [x] explorer(preview): content not sorted
- [x] add integration test for Explorer
- [x] bind "o" to open/close file/folder
- [x] bind "C-n/C-p" to up/down
- [x] bind "="/"_" to zoom-in/zoom-out
- [x] Sticky ancestors
- [x] remove unwrap and expect
- [x] bug(tree): zb does not work, because clash with explorer 'b'
- [x] Toggle preview
- [] search highlight matching word
- [] Error didn't clear
- [] should preview be there by default?
- [] Fix panic bugs (see github comments)
- [] explorer(preview): overflow where bufferline is there
- [] symlink not showing
1 change: 1 addition & 0 deletions helix-term/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
test-explorer
wongjiahau marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions helix-term/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,5 @@ helix-loader = { version = "0.6", path = "../helix-loader" }
smallvec = "1.10"
indoc = "2.0.0"
tempfile = "3.3.0"
pretty_assertions = "1.3.0"
build-fs-tree = "0.4.1"
wongjiahau marked this conversation as resolved.
Show resolved Hide resolved
47 changes: 46 additions & 1 deletion helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,10 @@ impl MappableCommand {
decrement, "Decrement item under cursor",
record_macro, "Record macro",
replay_macro, "Replay macro",
command_palette, "Open command palette",
command_palette, "Open command pallete",
wongjiahau marked this conversation as resolved.
Show resolved Hide resolved
open_or_focus_explorer, "Open or focus explorer",
reveal_current_file, "Reveal current file in explorer",
close_explorer, "close explorer",
);
}

Expand Down Expand Up @@ -2431,6 +2434,48 @@ fn file_picker_in_current_directory(cx: &mut Context) {
cx.push_layer(Box::new(overlayed(picker)));
}

fn open_or_focus_explorer(cx: &mut Context) {
cx.callback = Some(Box::new(
|compositor: &mut Compositor, cx: &mut compositor::Context| {
if let Some(editor) = compositor.find::<ui::EditorView>() {
match editor.explorer.as_mut() {
Some(explore) => explore.content.focus(),
None => match ui::Explorer::new(cx) {
Ok(explore) => editor.explorer = Some(overlayed(explore)),
Err(err) => cx.editor.set_error(format!("{}", err)),
},
}
}
},
));
}

fn reveal_current_file(cx: &mut Context) {
cx.callback = Some(Box::new(
|compositor: &mut Compositor, cx: &mut compositor::Context| {
if let Some(editor) = compositor.find::<ui::EditorView>() {
(|| match editor.explorer.as_mut() {
wongjiahau marked this conversation as resolved.
Show resolved Hide resolved
Some(explore) => explore.content.reveal_current_file(cx),
None => {
editor.explorer = Some(overlayed(ui::Explorer::new(cx)?));
let explorer = editor.explorer.as_mut().unwrap();
explorer.content.reveal_current_file(cx)
}
})()
.unwrap_or_else(|err| cx.editor.set_error(err.to_string()))
}
},
));
}

fn close_explorer(cx: &mut Context) {
cx.callback = Some(Box::new(|compositor: &mut Compositor, _| {
if let Some(editor) = compositor.find::<ui::EditorView>() {
editor.explorer.take();
}
}));
}

fn buffer_picker(cx: &mut Context) {
let current = view!(cx.editor).doc;

Expand Down
2 changes: 2 additions & 0 deletions helix-term/src/keymap/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ pub fn default() -> HashMap<Mode, Keymap> {
"r" => rename_symbol,
"h" => select_references_to_symbol_under_cursor,
"?" => command_palette,
"e" => reveal_current_file,
Comment on lines 279 to +280
Copy link
Member

Choose a reason for hiding this comment

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

Let's move this binding up so that it's just under F. Then the file commands are grouped.

"E" => open_or_focus_explorer,
},
"z" => { "View"
"z" | "c" => align_view_center,
Expand Down
Loading