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

[WIP] Bugfix/vcs deactivation race condition #2453

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
52e82ba
add p-queue and wait till queue is idle before calling deactivateProv…
akinsho Jul 23, 2018
a691b1a
correctly return deactivation promise and await it
akinsho Jul 24, 2018
e87bf78
fix vcs deregistering test
akinsho Jul 24, 2018
02e94bc
Merge branch 'master' of https://github.com/onivim/oni into feature/a…
akinsho Jul 24, 2018
32c6e7d
convert deactivateProvider to async/await
akinsho Jul 25, 2018
c667874
Move API out (#2459)
TalAmuyal Jul 25, 2018
c465082
Feature/ Indent lines improvements (#2446)
akinsho Jul 25, 2018
d471144
Fix + tidy descriptions of Explorer commands (#2460)
feltech Jul 26, 2018
06f476c
Add Lennaert Meijvogel as a backer - thank you! :)
bryphe Jul 26, 2018
97f643e
remove cursor moved audit time add scroll observable to close signatu…
akinsho Jul 26, 2018
0d20916
Bump oni-neovim-binaries version. (#2461)
CrossR Jul 26, 2018
759918d
Ignore Yarn from Linguist. (#2462)
CrossR Jul 26, 2018
b901ecd
Markdown Syntax Highlights (#2332)
CrossR Jul 26, 2018
e2c3fef
Feature/uncommit unstage functionality (#2457)
akinsho Jul 26, 2018
b6bdb4b
Explorer: Locate Current Buffer (#2429)
feltech Jul 26, 2018
b2ef17f
Jump to files/directories created in the Explorer (#2468)
feltech Jul 27, 2018
b921412
Add the CLI scripts back to the build command. (#2463)
CrossR Jul 27, 2018
97f0c61
Refocus previously open menu on reactivating Oni (#2472)
feltech Jul 29, 2018
25ab4a2
Revert "Refocus previously open menu on reactivating Oni" (#2478)
akinsho Jul 30, 2018
70388b1
Add Jonas Strømsodd as a backer - thank you! :)
bryphe Aug 1, 2018
2c03e73
Move API to oni-api and use it in preparetion for pluginization (#2473)
TalAmuyal Aug 2, 2018
66a13f5
Feature/git blame layer (#2469)
akinsho Aug 2, 2018
60c647e
Fix sidebar search (#2489)
TalAmuyal Aug 5, 2018
a54bb2c
Fix local building issue (#2488)
TalAmuyal Aug 9, 2018
795636c
Bugfix/commit loading (#2492)
akinsho Aug 16, 2018
127a2bc
Bugfix/buffer scrollbar fixes (#2495)
akinsho Aug 19, 2018
dd4b33d
Fix for 2272 - <f12> opens in current tab (#2504)
psxpaul Aug 19, 2018
910559c
Changed spacing of elements in the explorer sidebar to be more readab…
g-erson Aug 20, 2018
2fd82f3
Feature/Color-highlight improvements (#2447)
akinsho Aug 21, 2018
e3f65e6
Feature/oni sessions (#2479)
akinsho Aug 22, 2018
e482ae8
Fix for #2414 - truncated copy/paste (#2515)
psxpaul Aug 27, 2018
e612eb8
Bugfix/fix welcome buffer layer (#2522)
akinsho Aug 28, 2018
4ce6b22
Fix bug when pasting in command line mode (#2528)
psxpaul Aug 29, 2018
a396537
Add commands to jump to previous/next error (#2526)
psxpaul Aug 29, 2018
5beff5f
Feature/add sessions to welcome (#2527)
akinsho Aug 30, 2018
b17bac2
add p-queue and wait till queue is idle before calling deactivateProv…
akinsho Jul 23, 2018
5afbf17
correctly return deactivation promise and await it
akinsho Jul 24, 2018
28ba31c
fix vcs deregistering test
akinsho Jul 24, 2018
faa26b6
convert deactivateProvider to async/await
akinsho Jul 25, 2018
436ab91
fix any typing of unhandledrejection handler
akinsho Aug 31, 2018
be21fe1
Use utility attempt function to call vcs methods
akinsho Aug 31, 2018
74966ad
move call to initialize to after activate :shrug:"
akinsho Aug 31, 2018
7e9ef86
merge remote version fix conflicts
akinsho Aug 31, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

# Declare text files that will always have LF line endings on checking
oni eol=lf

# Ignore the yarn library from Linguist, for the Github Language Stats.
lib/yarn/* linguist-vendored=true
2 changes: 2 additions & 0 deletions .github/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ backers:
- 8832878
- 5127194
- 1764368
- 468548
- 2318955
2 changes: 2 additions & 0 deletions BACKERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ Thanks you to all our backers for making Oni possible!
* Doug Beney
* Aditya Gudimella
* Michal Hantl
* Lennaert Meijvogel
* Jonas Strømsodd

<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
29 changes: 10 additions & 19 deletions browser/src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const start = async (args: string[]): Promise<void> => {
const themesPromise = import("./Services/Themes")
const iconThemesPromise = import("./Services/IconThemes")

const sessionManagerPromise = import("./Services/Sessions")
const sidebarPromise = import("./Services/Sidebar")
const overlayPromise = import("./Services/Overlay")
const statusBarPromise = import("./Services/StatusBar")
Expand Down Expand Up @@ -182,6 +183,8 @@ export const start = async (args: string[]): Promise<void> => {
pluginManager.discoverPlugins()
Performance.endMeasure("Oni.Start.Plugins.Discover")

const oniApi = pluginManager.getApi()

Performance.startMeasure("Oni.Start.Themes")
const Themes = await themesPromise
const IconThemes = await iconThemesPromise
Expand Down Expand Up @@ -215,7 +218,6 @@ export const start = async (args: string[]): Promise<void> => {

const StatusBar = await statusBarPromise
StatusBar.activate(configuration)
const statusBar = StatusBar.getInstance()

const Overlay = await overlayPromise
Overlay.activate()
Expand Down Expand Up @@ -261,7 +263,7 @@ export const start = async (args: string[]): Promise<void> => {
const tasks = Tasks.getInstance()

const LanguageManager = await languageManagerPromise
LanguageManager.activate(configuration, editorManager, pluginManager, statusBar, workspace)
LanguageManager.activate(oniApi)
const languageManager = LanguageManager.getInstance()

Performance.startMeasure("Oni.Start.Editors")
Expand Down Expand Up @@ -315,24 +317,9 @@ export const start = async (args: string[]): Promise<void> => {
const sidebarManager = Sidebar.getInstance()

const VCSManager = await vcsManagerPromise
VCSManager.activate(
workspace,
editorManager,
statusBar,
commandManager,
menuManager,
sidebarManager,
notifications,
configuration,
)
VCSManager.activate(oniApi, sidebarManager, notifications)

Explorer.activate(
commandManager,
configuration,
editorManager,
Sidebar.getInstance(),
workspace,
)
Explorer.activate(oniApi, configuration, Sidebar.getInstance())
Learning.activate(
commandManager,
configuration,
Expand All @@ -341,6 +328,10 @@ export const start = async (args: string[]): Promise<void> => {
Sidebar.getInstance(),
WindowManager.windowManager,
)

const Sessions = await sessionManagerPromise
Sessions.activate(oniApi, sidebarManager)

Performance.endMeasure("Oni.Start.Sidebar")

const createLanguageClientsFromConfiguration =
Expand Down
28 changes: 16 additions & 12 deletions browser/src/Editor/BufferManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,25 +338,29 @@ export class Buffer implements IBuffer {
public handleInput(key: string): boolean {
const state = this._store.getState()

const layers: IBufferLayer[] = state.layers[this._id]
const bufferLayers: IBufferLayer[] = state.layers[this._id]

if (!layers || !layers.length) {
if (!bufferLayers || !bufferLayers.length) {
return false
}

const result = layers.reduce<boolean>((prev, curr) => {
if (prev) {
return true
}
const layerShouldHandleInput = bufferLayers.reduce<boolean>(
(layerHandlerExists, currentLayer) => {
if (layerHandlerExists) {
return true
}

if (!curr || !curr.handleInput) {
if (!currentLayer || !currentLayer.handleInput) {
return false
} else if (currentLayer.isActive && currentLayer.isActive()) {
return currentLayer.handleInput(key)
}
return false
} else {
return curr.handleInput(key)
}
}, false)
},
false,
)

return result
return layerShouldHandleInput
}
public async updateHighlights(
tokenColors: TokenColor[],
Expand Down
17 changes: 8 additions & 9 deletions browser/src/Editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,10 @@ import * as types from "vscode-languageserver-types"

import { Disposable } from "./../Utility"

export interface IEditor extends Oni.Editor {
// Methods
init(filesToOpen: string[]): void
render(): JSX.Element

setSelection(selectionRange: types.Range): Promise<void>
}

/**
* Base class for Editor implementations
*/
export class Editor extends Disposable implements Oni.Editor {
export abstract class Editor extends Disposable implements Oni.Editor {
private _currentMode: string
private _onBufferEnterEvent = new Event<Oni.EditorBufferEventArgs>()
private _onBufferLeaveEvent = new Event<Oni.EditorBufferEventArgs>()
Expand All @@ -44,7 +36,10 @@ export class Editor extends Disposable implements Oni.Editor {
return this._onCursorMoved
}

public abstract init(filesToOpen: string[]): void

// Events

public get onModeChanged(): IEvent<Oni.Vim.Mode> {
return this._onModeChangedEvent
}
Expand Down Expand Up @@ -90,6 +85,10 @@ export class Editor extends Disposable implements Oni.Editor {
return Promise.reject("Not implemented")
}

public abstract render(): JSX.Element

public abstract setSelection(selectionRange: types.Range): Promise<void>

protected setMode(mode: Oni.Vim.Mode): void {
if (mode !== this._currentMode) {
this._currentMode = mode
Expand Down
8 changes: 8 additions & 0 deletions browser/src/Editor/NeovimEditor/BufferLayerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type BufferFilter = (buf: Oni.Buffer) => boolean

export interface IBufferLayer extends Oni.BufferLayer {
handleInput?: (key: string) => boolean
isActive?: () => boolean
}

export const createBufferFilterFromLanguage = (language: string) => (buf: Oni.Buffer): boolean => {
Expand Down Expand Up @@ -69,6 +70,13 @@ export class BufferLayerManager {
}
}

const getInstance = (() => {
const instance = new BufferLayerManager()
return () => instance
})()

export default getInstance

export const wrapReactComponentWithLayer = (
id: string,
component: JSX.Element,
Expand Down
20 changes: 4 additions & 16 deletions browser/src/Editor/NeovimEditor/Definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export enum OpenType {
export class Definition {
constructor(private _editor: Oni.Editor, private _store: Store<State.IState>) {}

public async gotoDefinitionUnderCursor(openType: OpenType = OpenType.NewTab): Promise<void> {
public async gotoDefinitionUnderCursor(openOptions?: Oni.FileOpenOptions): Promise<void> {
const activeDefinition = this._store.getState().definition

if (!activeDefinition) {
Expand All @@ -31,33 +31,21 @@ export class Definition {
const line = range.start.line
const column = range.start.character

await this.gotoPositionInUri(uri, line, column, openType)
await this.gotoPositionInUri(uri, line, column, openOptions)
}

public async gotoPositionInUri(
uri: string,
line: number,
column: number,
openType: OpenType = OpenType.NewTab,
openOptions?: Oni.FileOpenOptions,
): Promise<void> {
const filePath = Helpers.unwrapFileUriPath(uri)

const activeEditor = this._editor
const command = this._getCommandFromOpenType(openType)

await activeEditor.neovim.command(`${command} ${filePath}`)
await this._editor.openFile(filePath, openOptions)
await activeEditor.neovim.command(`cal cursor(${line + 1}, ${column + 1})`)
await activeEditor.neovim.command("norm zz")
}

private _getCommandFromOpenType(openType: OpenType) {
switch (openType) {
case OpenType.SplitVertical:
return "vsp"
case OpenType.SplitHorizontal:
return "sp"
default:
return "e"
}
}
}
8 changes: 5 additions & 3 deletions browser/src/Editor/NeovimEditor/HoverRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import * as React from "react"
import * as types from "vscode-languageserver-types"

import getTokens from "./../../Services/SyntaxHighlighting/TokenGenerator"
import { enableMouse } from "./../../UI/components/common"
import styled, { enableMouse } from "./../../UI/components/common"
import { ErrorInfo } from "./../../UI/components/ErrorInfo"
import { QuickInfoElement, QuickInfoWrapper } from "./../../UI/components/QuickInfo"
import { QuickInfoElement } from "./../../UI/components/QuickInfo"
import QuickInfoWithTheme from "./../../UI/components/QuickInfoContainer"

import * as Helpers from "./../../Plugins/Api/LanguageClient/LanguageClientHelpers"
Expand All @@ -22,7 +22,9 @@ import { IToolTipsProvider } from "./ToolTipsProvider"

const HoverToolTipId = "hover-tool-tip"

const HoverRendererContainer = QuickInfoWrapper.extend`
const HoverRendererContainer = styled.div`
user-select: none;
cursor: default;
${enableMouse};
`

Expand Down
47 changes: 21 additions & 26 deletions browser/src/Editor/NeovimEditor/NeovimBufferLayersView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import { NeovimActiveWindow } from "./NeovimActiveWindow"

import * as State from "./NeovimEditorStore"

import { StackLayer } from "../../UI/components/common"
import { EmptyArray } from "./../../Utility"
import styled, { StackLayer } from "../../UI/components/common"

export interface NeovimBufferLayersViewProps {
activeWindowId: number
Expand All @@ -25,23 +24,26 @@ export interface NeovimBufferLayersViewProps {
fontPixelHeight: number
}

const InnerLayerStyle: React.CSSProperties = {
position: "absolute",
top: "0px",
left: "0px",
right: "0px",
bottom: "0px",
overflowY: "auto",
overflowX: "auto",
const InnerLayer = styled.div`
position: absolute;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
overflow: hidden;
`

export interface LayerContextWithCursor extends Oni.BufferLayerRenderContext {
cursorLine: number
cursorColumn: number
}

export class NeovimBufferLayersView extends React.PureComponent<NeovimBufferLayersViewProps, {}> {
public render(): JSX.Element {
const containers = this.props.windows.map(windowState => {
const layers =
this.props.layers[windowState.bufferId] || (EmptyArray as Oni.BufferLayer[])
const layers: Oni.BufferLayer[] = this.props.layers[windowState.bufferId] || []

const layerContext: Oni.BufferLayerRenderContext = {
const layerContext: LayerContextWithCursor = {
isActive: windowState.windowId === this.props.activeWindowId,
windowId: windowState.windowId,
fontPixelWidth: this.props.fontPixelWidth,
Expand All @@ -53,22 +55,15 @@ export class NeovimBufferLayersView extends React.PureComponent<NeovimBufferLaye
visibleLines: windowState.visibleLines,
topBufferLine: windowState.topBufferLine,
bottomBufferLine: windowState.bottomBufferLine,
cursorColumn: windowState.column,
cursorLine: windowState.line,
}

const layerElements = layers.map(l => {
const layerElements = layers.map(layer => {
return (
<div
key={
l.id +
"." +
windowState.windowId.toString() +
"." +
windowState.bufferId.toString()
}
style={InnerLayerStyle}
>
{l.render(layerContext)}
</div>
<InnerLayer key={`${layer.id}.${windowState.windowId}.${windowState.bufferId}`}>
{layer.render(layerContext)}
</InnerLayer>
)
})

Expand Down
Loading