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

feat(editor): folder drag and drop #2155

Merged
merged 3 commits into from
Jul 21, 2020
Merged

Conversation

zbaylin
Copy link
Member

@zbaylin zbaylin commented Jul 21, 2020

As of right now, we only support dropping files onto the editor. This adds the behavior that if you drop a folder/directory onto the editor, it will change the directory in the same way that :cd x/y/z changes the directory.

@@ -183,7 +183,7 @@ type t =
| Pane(Feature_Pane.msg)
| PaneTabClicked(Feature_Pane.pane)
| PaneCloseButtonClicked
| VimDirectoryChanged(string)
| DirectoryChanged(string)
Copy link
Member Author

Choose a reason for hiding this comment

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

I debated whether or not I should add a duplicate variant to distinguish the vim :cd from other possible directory changes, but looking where this is used, it doesn't seem super specific to vim. Let me know if you think I should change it.

Copy link
Member

Choose a reason for hiding this comment

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

Seems reasonable - it is more general than Vim!

@zbaylin zbaylin requested a review from bryphe July 21, 2020 15:27
Noop;
switch (stats.st_kind) {
| S_REG => OpenFileByPath(path, None, None)
| S_DIR => DirectoryChanged(path)
Copy link
Member

Choose a reason for hiding this comment

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

One thing I'd expect in this case is that we'd chdir to change the working directory of the process, too. Dispatching the DirectoryChanged event tells our internal state the directory is changed, but doesn't actually change the working directory of the process.

We'd probably want to use Luv.Path.chdir to change the work directory, and then - /~https://github.com/aantron/luv/blob/bb11498de65a2acb56a7269801c1d2ba41672179/src/path.mli#L18 - if that is successful, dispatch the DirectoryChanged event.

Copy link
Member

Choose a reason for hiding this comment

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

If the working directory isn't in sync - our file explorer and stuff will show the 'correct' directory, but when running vim commands like :e some/file it would be relative to the previous directory.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a great point, I hadnt thought of that. Thanks! Will fix now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just fixed in fe2985c!

Copy link
Member

@bryphe bryphe left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks for setting up the chdir 👍

@zbaylin
Copy link
Member Author

zbaylin commented Jul 21, 2020

/azp run

@zbaylin zbaylin merged commit b53bf49 into master Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants