-
Notifications
You must be signed in to change notification settings - Fork 283
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(workspace): add drag and drop support to EditorView #1759
Changes from 2 commits
3bb0cdd
4e3f3ee
718199c
97d500b
bbdd475
9e38c89
1ee83a2
35a4832
88b4b71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[@deriving show({with_path: false})] | ||
type msg = | ||
| FilesDroppedOnEditor({paths: list(string)}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(library | ||
(name Feature_FileDrop) | ||
bryphe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(public_name Oni2.feature.filedrop) | ||
(libraries | ||
Oni2.core | ||
isolinear | ||
base | ||
Revery | ||
) | ||
(preprocess (pps ppx_let ppx_deriving.show brisk-reconciler.ppx))) |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -186,6 +186,25 @@ let update = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| None => (state, Effect.none) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FileDrop(msg) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let eff = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
switch (msg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FilesDroppedOnEditor({paths}) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Isolinear.Effect.createWithDispatch( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
~name="feature.filedrop.openFiles", dispatch => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
List.iter( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
path => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
let stats = Unix.stat(path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
bryphe marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (stats.st_kind == S_REG) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dispatch(OpenFileByPath(path, None, None)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
paths, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ir would be nice to have this effect moved out of the update function, to avoid it turning into a blob. I also think ti does too much. Ideally this would be two separate effects, one for the This area is still a bit murky with a lot of historical baggage and few good examples of how to do these things properly, so don't worry too much about it, but the general lesson here is that supplying the message to be dispatched when it is invoked allows effects to be generalized. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's one example of such an effect: oni2/src/Store/FileExplorerStore.re Lines 11 to 25 in d971dae
Used here: oni2/src/Store/FileExplorerStore.re Lines 52 to 59 in d971dae
And another: oni2/src/Feature/SCM/Feature_SCM.re Lines 65 to 74 in d971dae
Used here: oni2/src/Store/ExtensionClientStoreConnector.re Lines 246 to 249 in d971dae
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bryphe and I worked this out last night and I think the consensus we came to was that eventually the drag and drop feature will have it's own state once the drag part is implemented. I.e. if you held a dragged file over a certain area for x amount of time, something happens, etc. I'm obviously not as familiar with the underlying architecture as the two of you are, so it's possible @bryphe is able to explain better than I am. I understand what you mean with regards to separating the actions -- I can do that. Thanks for the examples! |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(state, eff); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// TODO: This should live in the editor feature project | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EditorFont(Service_Font.FontLoaded(font)) => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{...state, editorFont: font}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might seem small for now, but this is the perfect place for us to add a model once we incorporate dragging 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to admit I'm a bit more concerned. Not so much because of the granularity, although that is a minor concern too, but more because this seems to be a cross-cutting concern. It's not clear to me how this will integrate with other features that need to support drag and drop. Why would dropping a file on the file explorer, for example, even need to involve a separate file drop feature project? It seems like very little code would live here, but would instead have to be implemented in the consuming feature projects (file explorer/workspace) or in the glue code, as is largely the case here.
I can see that there's a missing feature project here for this specific feature to live in however, but I think that missing project is for the workspace as a whole.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I think this is a fair concern! It seems like - at least the way this is implemented right now -
FilesDroppedOnEditor
- makes sense to be part of theFeature_Editor
(since it's handling the use-case where a file is dropped on the editors, and not on the explorer or other parts of the shell, at the moment).The main issue is that
Editor
is one of our least-factored features at the moment - we don't have a centralmsg
orupdater
yet.We could start a
Feature_Editor.msg
withFilesDropped
, and stub out an updater - and then incrementally move the remaining functionality towards that (ie, there are lots ofEditor*
actions inActions.t
that could be migrated to thismsg
later).