Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Commit

Permalink
Fix #471, enable opening a file by drag-dropping it onto Oni (#472)
Browse files Browse the repository at this point in the history
* enable opening a file by drag-dropping a file onto Oni

* handle multiple files dropped at once and handle potential windows wackiness

* keep behavior consistent regardless of if a single file or multiple files are provided
  • Loading branch information
keforbes authored and extr0py committed Jun 3, 2017
1 parent b5ea293 commit 5fe6de0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions browser/src/Editor/NeovimEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,22 @@ export class NeovimEditor implements IEditor {
this._neovimInstance.command("exec \":normal! " + message + "\"")
}
})

// enable opening a file via drag-drop
document.ondragover = (ev) => {
ev.preventDefault()
}
document.body.ondrop = (ev) => {
ev.preventDefault()

let files = ev.dataTransfer.files
// open first file in current editor
this._neovimInstance.open(files[0].path.split("\\").join("/"))
// open any subsequent files in new tabs
for (let i = 1; i < files.length; i++) {
this._neovimInstance.command("exec \":tabe " + files.item(i).path.split("\\").join("/") + "\"")
}
}
}

public init(filesToOpen: string[]): void {
Expand Down

0 comments on commit 5fe6de0

Please sign in to comment.