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

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
bryphe committed May 3, 2018
2 parents 3569110 + eaf6695 commit 4aaffa7
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 19 deletions.
3 changes: 3 additions & 0 deletions BACKERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Thanks you to all our backers for making Oni possible!
## VIP Backers via Patreon

* @mikl
* Tom Boland

## Backers via BountySource

Expand Down Expand Up @@ -113,6 +114,8 @@ Thanks you to all our backers for making Oni possible!
* Troy Vitullo
* Leo Critchley
* Patrick Massot
* Jerome Pellois
* Wesley Moore

<a href="https://opencollective.com/oni/tiers/backer/0/website" target="_blank"><img src="https://opencollective.com/oni/tiers/backer/0/avatar.png"></a>
<a href="https://opencollective.com/oni/tiers/backer/1/website" target="_blank"><img src="https://opencollective.com/oni/tiers/backer/1/avatar.png"></a>
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ install:
- node --version
- npm --version
# install modules
- yarn install --verbose
- yarn install
- npm run check-cached-binaries

artifacts:
Expand Down
8 changes: 7 additions & 1 deletion browser/src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,13 @@ export const start = async (args: string[]): Promise<void> => {
Sidebar.activate(configuration, workspace)
const sidebarManager = Sidebar.getInstance()

Explorer.activate(commandManager, editorManager, Sidebar.getInstance(), workspace)
Explorer.activate(
commandManager,
configuration,
editorManager,
Sidebar.getInstance(),
workspace,
)
Search.activate(commandManager, editorManager, Sidebar.getInstance(), workspace)
Learning.activate(
commandManager,
Expand Down
5 changes: 3 additions & 2 deletions browser/src/Input/KeyBindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ export const applyDefaultKeyBindings = (oni: Oni.Plugin.Api, config: Configurati
input.bind("<enter>", "menu.select")
input.bind(["<enter>", "<space>"], "select")

input.bind("<delete>", "explorer.delete")

// TODO: Scope 's' to just the local window
input.bind("<c-g>", "sneak.show", () => isNormalMode() && !menu.isMenuOpen())
input.bind(["<esc>", "<c-c>"], "sneak.hide")
Expand All @@ -135,7 +133,9 @@ export const applyDefaultKeyBindings = (oni: Oni.Plugin.Api, config: Configurati

// Explorer
input.bind("d", "explorer.delete.persist", isExplorerActive)
input.bind("<c-delete>", "explorer.delete.persist", isExplorerActive)
input.bind("<c-d>", "explorer.delete", isExplorerActive)
input.bind("<delete>", "explorer.delete", isExplorerActive)
input.bind("y", "explorer.yank", isExplorerActive)
input.bind("p", "explorer.paste", isExplorerActive)
input.bind("u", "explorer.undo", isExplorerActive)
Expand All @@ -144,6 +144,7 @@ export const applyDefaultKeyBindings = (oni: Oni.Plugin.Api, config: Configurati
input.bind("r", "explorer.rename", isExplorerActive)
input.bind("<c-e>", "explorer.create.file", isExplorerActive)
input.bind("<c-f>", "explorer.create.folder", isExplorerActive)
input.bind("<c-r>", "explorer.refresh", isExplorerActive)

// Browser
input.bind("k", "browser.scrollUp")
Expand Down
46 changes: 33 additions & 13 deletions browser/src/Services/Explorer/ExplorerSplit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { FileSystemWatcher } from "./../../Services/FileSystemWatcher"
import { Event } from "oni-types"

import { CallbackCommand, CommandManager } from "./../../Services/CommandManager"
import { Configuration } from "./../../Services/Configuration"
import { EditorManager } from "./../../Services/EditorManager"
import { getInstance as NotificationsInstance } from "./../../Services/Notifications"
import { windowManager } from "./../../Services/WindowManager"
Expand All @@ -27,8 +28,8 @@ type Node = ExplorerSelectors.ExplorerNode
export class ExplorerSplit {
private _onEnterEvent: Event<void> = new Event<void>()
private _selectedId: string = null

private _store: Store<IExplorerState>
private _watcher: FileSystemWatcher = null

public get id(): string {
return "oni.sidebar.explorer"
Expand All @@ -39,26 +40,25 @@ export class ExplorerSplit {
}

constructor(
// private _configuration: Configuration,
private _configuration: Configuration,
private _workspace: IWorkspace,
private _commandManager: CommandManager,
private _editorManager: EditorManager,
) {
this._store = createStore({ notifications: NotificationsInstance() })

const Watcher = new FileSystemWatcher({
target: this._workspace.activeWorkspace,
options: { ignoreInitial: true, ignored: "**/node_modules" },
})
this._initializeFileSystemWatcher()

this._workspace.onDirectoryChanged.subscribe(newDirectory => {
this._store.dispatch({
type: "SET_ROOT_DIRECTORY",
rootPath: newDirectory,
})

Watcher.unwatch(this._workspace.activeWorkspace)
Watcher.watch(newDirectory)
if (this._watcher) {
this._watcher.unwatch(this._workspace.activeWorkspace)
this._watcher.watch(newDirectory)
}
})

if (this._workspace.activeWorkspace) {
Expand All @@ -67,11 +67,6 @@ export class ExplorerSplit {
rootPath: this._workspace.activeWorkspace,
})
}

const events = ["onChange", "onAdd", "onAddDir", "onMove", "onDelete", "onDeleteDir"]
events.forEach(event =>
Watcher[event].subscribe(() => this._store.dispatch({ type: "REFRESH" })),
)
}

public enter(): void {
Expand Down Expand Up @@ -104,11 +99,27 @@ export class ExplorerSplit {
)
}

private _initializeFileSystemWatcher(): void {
if (this._configuration.getValue("explorer.autoRefresh")) {
this._watcher = new FileSystemWatcher({
target: this._workspace.activeWorkspace,
options: { ignoreInitial: true, ignored: "**/node_modules" },
})

const events = ["onChange", "onAdd", "onAddDir", "onMove", "onDelete", "onDeleteDir"]
events.forEach(event => this._watcher[event].subscribe(() => this._refresh()))
}
}

private _inputInProgress = () => {
const { register: { rename, create } } = this._store.getState()
return rename.active || create.active
}

private _refresh(): void {
this._store.dispatch({ type: "REFRESH" })
}

private _initialiseExplorerCommands(): void {
this._commandManager.registerCommand(
new CallbackCommand(
Expand Down Expand Up @@ -153,6 +164,15 @@ export class ExplorerSplit {
),
)

this._commandManager.registerCommand(
new CallbackCommand(
"explorer.refresh",
"Explorer: Refresh the tree",
"Updates the explorer with the latest state on the file system",
() => !this._inputInProgress() && this._refresh(),
),
)

this._commandManager.registerCommand(
new CallbackCommand(
"explorer.create.file",
Expand Down
14 changes: 13 additions & 1 deletion browser/src/Services/Explorer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { CommandManager } from "./../CommandManager"
import { Configuration } from "./../Configuration"
import { EditorManager } from "./../EditorManager"
import { SidebarManager } from "./../Sidebar"
import { Workspace } from "./../Workspace"
Expand All @@ -13,9 +14,20 @@ import { ExplorerSplit } from "./ExplorerSplit"

export const activate = (
commandManager: CommandManager,
configuration: Configuration,
editorManager: EditorManager,
sidebarManager: SidebarManager,
workspace: Workspace,
) => {
sidebarManager.add("files-o", new ExplorerSplit(workspace, commandManager, editorManager))
configuration.registerSetting("explorer.autoRefresh", {
description:
"When set to true, the explorer will listen for changes on the file system and refresh automatically.",
requiresReload: true,
defaultValue: false,
})

sidebarManager.add(
"files-o",
new ExplorerSplit(configuration, workspace, commandManager, editorManager),
)
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "",
"email": "[email protected]",
"homepage": "https://www.onivim.io",
"version": "0.3.3",
"version": "0.3.4",
"description": "Code editor with a modern twist on modal editing - powered by neovim.",
"keywords": ["vim", "neovim", "text", "editor", "ide", "vim"],
"main": "./lib/main/src/main.js",
Expand Down

0 comments on commit 4aaffa7

Please sign in to comment.