Skip to content

Commit

Permalink
feat(editor): folder drag and drop (#2155)
Browse files Browse the repository at this point in the history
* Actions: rename VimDirectoryChanged -> DirectoryChanged

* FileDropped: hook up DirectoryChanged on directory dropped

* FileDrop: change working directory on directory change
  • Loading branch information
zbaylin authored Jul 21, 2020
1 parent b6ff469 commit b53bf49
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Model/Actions.re
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ type t =
| Pane(Feature_Pane.msg)
| PaneTabClicked(Feature_Pane.pane)
| PaneCloseButtonClicked
| VimDirectoryChanged(string)
| DirectoryChanged(string)
| VimExecuteCommand(string)
| VimMessageReceived({
priority: [@opaque] Vim.Types.msgPriority,
Expand Down
2 changes: 1 addition & 1 deletion src/Store/ExtensionClientStoreConnector.re
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ let start = (extensions, extHostClient: Exthost.Client.t) => {
),
)

| VimDirectoryChanged(path) => (state, changeWorkspaceEffect(path))
| DirectoryChanged(path) => (state, changeWorkspaceEffect(path))

| BufferEnter({id, filePath, _}) =>
let eff =
Expand Down
12 changes: 8 additions & 4 deletions src/Store/Features.re
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,14 @@ let update =
| FilesDropped({paths}) =>
let eff =
Service_OS.Effect.statMultiple(paths, (path, stats) =>
if (stats.st_kind == S_REG) {
OpenFileByPath(path, None, None);
} else {
Noop;
switch (stats.st_kind) {
| S_REG => OpenFileByPath(path, None, None)
| S_DIR =>
switch (Luv.Path.chdir(path)) {
| Ok () => DirectoryChanged(path)
| Error(_) => Noop
}
| _ => Noop
}
);
(state, eff);
Expand Down
4 changes: 2 additions & 2 deletions src/Store/VimStoreConnector.re
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ let start =

let _: unit => unit =
Vim.onDirectoryChanged(newDir =>
dispatch(Actions.VimDirectoryChanged(newDir))
dispatch(Actions.DirectoryChanged(newDir))
);

let _: unit => unit =
Expand Down Expand Up @@ -909,7 +909,7 @@ let start =
copyActiveFilepathToClipboardEffect,
)

| VimDirectoryChanged(workingDirectory) =>
| DirectoryChanged(workingDirectory) =>
let newState = {
...state,
workspace: {
Expand Down

0 comments on commit b53bf49

Please sign in to comment.