zedapp / zed

Rethinking code editing.
http://zedapp.org
MIT License
2.22k stars 162 forks source link

Zed should grow project-awareness. #519

Closed ghost closed 9 years ago

ghost commented 9 years ago

Currently, if I'm using a linux terminal, and I type 'zed /path/to/some/file', zed will open that file, but Ctrl-E will only let me navigate to other files within that directory. This is frustrating when the file opened is in a subdirectory of a larger git project, as zed's project-based navigation prevents me from seeing files outside that directory, even though they're part of the same git repo.

I think Zed's default behavior of opening a directory as a project works well, but when opening a file, zed should walk up the path looking for various source control files in order to determine what the "project" is.

I happen to have a simple shell script that does exactly this, zed would need some js equivalent of this:

    while ! test -d .bzr -o -d .git -o -d .svn -o -d .hg -o -d .cvs; do
        cd ..
    done

Super simple stuff ;-)

Can you point me at the part of the code where it loads files from the command line?

zefhemel commented 9 years ago

Yep, sounds like an idea :) Here's the relevant code: https://github.com/zedapp/zed/blob/master/app/js/cli.nw.js#L29

ghost commented 9 years ago

Hm, if I'm reading this correctly:

https://github.com/zedapp/zed/blob/master/app/js/cli.nw.js#L51

openUi.open(path, url);

path is the path to the project root dir, and url is the full path to the file to open, right?

zefhemel commented 9 years ago

Let me look that up for you: https://github.com/zedapp/zed/blob/master/app/js/open_ui.js#L263

First is the title (presented in the title bar), the second the URL (probably in the form: node:/home/bla/bla).

ghost commented 9 years ago

Hm, so where's the code that says "if url is a file, the project is the directory that contains that file"?

https://github.com/zedapp/zed/blob/master/app/js/history.nw.js#L79 Seems related but I'm having a hard time pinning down exactly where to implement this.

zefhemel commented 9 years ago

That's over here: https://github.com/zedapp/zed/blob/master/app/js/fs/node.js#L22