Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function activate(oni: any): any {
const onFocusEvent = new Event()
const oniApi: Oni.Plugin.Api = oni
// TODO: Add sidebar.add to the API and use oniApi instead of oni
oni.sidebar.add("search", new SearchPane(onFocusEvent, oni))
const sidebarManager = getSidebarManager() // TODO: Remove
const searchAllFiles = () => {
sidebarManager.toggleVisibilityById("oni.sidebar.search") // TODO: Use oni-api instead
// TODO: Add sidebar.setActiveEntry to the API and use oni as Oni (API)
// oni.sidebar.setActiveEntry("oni.sidebar.search")
onFocusEvent.dispatch()
}
oniApi.commands.registerCommand({
import { Event } from "oni-types"
import { EditorManager } from "./../../browser/src/Services/EditorManager"
const _onBufferSaved = new Event("Test:ActiveEditor-BufferSaved")
const _onBufferEnter = new Event("Test:ActiveEditor-BufferEnter")
const _onQuit = new Event()
const MockEditorManager = jest.fn().mockImplementation(() => ({
activeEditor: {
onQuit: _onQuit,
activeBuffer: {
filePath: "test.txt",
},
onBufferEnter: _onBufferEnter,
onBufferSaved: _onBufferSaved,
restoreSession: jest.fn(),
persistSession: jest.fn(),
getCurrentSession: jest.fn().mockReturnValue("test-session"),
},
}))
export default MockEditorManager
public subscribeToLanguageServerNotification(
protocolMessage: string,
callback: (args: ILanguageServerNotificationResponse) => void,
): IDisposable {
const currentSubscription = this._notificationSubscriptions[protocolMessage]
if (!currentSubscription) {
const evt = new Event()
this._notificationSubscriptions[protocolMessage] = evt
const languageClients = Object.values(this._languageServerInfo)
languageClients.forEach(ls => {
ls.subscribe(protocolMessage, evt)
})
return evt.subscribe(args => callback(args))
} else {
return currentSubscription.subscribe(args => callback(args))
}
}
public registerSetting(
name: string,
options: IConfigurationSettingMetadata = DefaultConfigurationSettings,
): IConfigurationSetting {
this._settingMetadata[name] = options
const currentValue = this.getValue(name, null)
if (options.defaultValue && currentValue === null) {
this.setValue(name, options.defaultValue)
}
const newEvent = new Event>()
const subs: Array>> =
this._subscriptions[name] || []
this._subscriptions[name] = [...subs, newEvent]
const dispose = () => {
this._subscriptions[name] = this._subscriptions[name].filter(e => e !== newEvent)
}
const getValue = () => {
return this.getValue(name)
}
return {
onValueChanged: newEvent,
dispose,
getValue,