Skip to content

Commit cd55060

Browse files
committed
docs: add a finder table to the ARCHITECTURE document
1 parent 6976209 commit cd55060

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

ARCHITECTURE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,36 @@ Again, only documenting the differences:
7272
2. Like `commandt.file_finder()`, this function doesn't do anything special with config; it just forwards `options`.
7373
3. Unlike `commandt.file_finder()`, we don't `pushd`, and we don't pass in an `on_close` that does `popd` either, because watchman doesn't need to change directory to do its job. However, it _does_ require us to pass an `on_open()` that does the `relativize()` trick.
7474

75+
## Summary of finder life-cycles
76+
77+
| Command | Argument? | Finder function | Variant | Mode | Context? | `on_directory`? | `pushd`? | `on_close`/`popd`? |
78+
| ------------------- | --------- | ----------------- | ------- | --------- | -------- | --------------- | -------- | ------------------ |
79+
| `:CommandTBuffer` | none | `finder` | list | 'file' | no | no | no | no |
80+
| `:CommandTCommand` | none | `finder` | list | 'virtual' | no | no | no | no |
81+
| `:CommandTFd` | directory | `finder` | command | 'file' | no | yes | yes | yes |
82+
| `:CommandTFind` | directory | `finder` | command | 'file' | no | yes | yes | yes |
83+
| `:CommandTGit` | directory | `finder` | command | 'file' | no | yes | no | no |
84+
| `:CommandTHelp` | none | `finder` | list | 'virtual' | no | no | no | no |
85+
| `:CommandTHistory` | none | `finder` | list | 'virtual' | no | no | no | no |
86+
| `:CommandTJump` | none | `finder` | list | 'virtual' | no | no | no | no |
87+
| `:CommandTLine` | none | `finder` | list | 'virtual' | no | no | no | no |
88+
| `:CommandTRipgrep` | directory | `finder` | command | 'file' | no | yes | yes | yes |
89+
| `:CommandTSearch` | none | `finder` | list | 'virtual' | no | no | no | no |
90+
| `:CommandTTag` | none | `finder` | list | 'virtual' | yes | no | no | no |
91+
| `:CommandTWatchman` | directory | `watchman_finder` | n/a | 'file' | no | no | no | no |
92+
| `:CommandT` | directory | `file_finder` | n/a | 'file' | no | no | yes | yes |
93+
94+
Legend:
95+
96+
- Argument?: Does the commmand accept an argument?
97+
- Finder function: What is the `commandt` function that serves as entry point?
98+
- Variant: Does the finder use a list scanner (ie. `candidates`) or a command scanner (ie. `command`)?
99+
- Mode: Is the finder a "file" finder (shows icons) or a "virtual" one?
100+
- Context?: Does the finder make use of the `context` parameter to pass state?
101+
- `on_directory`?: Does the finder use an `on_directory` callback to infer a starting directory if appropriate?
102+
- `pushd`?: Does the finder use `pushd()` before scanning?
103+
- `on_close`/`popd`?: Does the finder use an `on_close` callback and `popd` to go back to the previous directory when closing its UI (and optionally opening a selection)?
104+
75105
# Memory model
76106

77107
For maximum performance, Command-T takes great pains to avoid unnecessary copying. This, combined with the fact that memory is passing across Lua's FFI boundary to and from C code, means that there are some subtleties to the question of which code owns any particular piece of memory, and who is responsible for freeing it (either manually from the C code, or automatically via garbage collection initiated on the Lua side).

0 commit comments

Comments
 (0)