Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
destroy() {
// console.log('DESTROY variables', this.now);
this.liveFlag = false;
etch.destroy(this);
this.disposables.dispose();
}
}
})
atom.commands.dispatch(workspaceElement, 'key-binding-resolver:toggle')
// Not partial because it dispatches the command for `x` immediately due to only having keyup events in remainder of partial match
document.dispatchEvent(atom.keymaps.constructor.buildKeydownEvent('x', {target: workspaceElement}))
await etch.getScheduler().getNextUpdatePromise()
expect(workspaceElement.querySelector('.key-binding-resolver .keystroke').textContent).toBe('x')
expect(workspaceElement.querySelectorAll('.key-binding-resolver .used')).toHaveLength(1)
expect(workspaceElement.querySelectorAll('.key-binding-resolver .unused')).toHaveLength(0)
expect(workspaceElement.querySelectorAll('.key-binding-resolver .unmatched')).toHaveLength(1)
// It should not render the keyup event data because there is no match
document.dispatchEvent(atom.keymaps.constructor.buildKeyupEvent('x', {target: workspaceElement}))
await etch.getScheduler().getNextUpdatePromise()
expect(workspaceElement.querySelector('.key-binding-resolver .keystroke').textContent).toBe('x ^x')
expect(workspaceElement.querySelectorAll('.key-binding-resolver .used')).toHaveLength(1)
expect(workspaceElement.querySelectorAll('.key-binding-resolver .unused')).toHaveLength(0)
expect(workspaceElement.querySelectorAll('.key-binding-resolver .unmatched')).toHaveLength(0)
document.dispatchEvent(atom.keymaps.constructor.buildKeydownEvent('a', {target: workspaceElement}))
await etch.getScheduler().getNextUpdatePromise()
expect(workspaceElement.querySelector('.key-binding-resolver .keystroke').textContent).toBe('a (partial)')
expect(workspaceElement.querySelectorAll('.key-binding-resolver .used')).toHaveLength(0)
expect(workspaceElement.querySelectorAll('.key-binding-resolver .unused')).toHaveLength(1)
expect(workspaceElement.querySelectorAll('.key-binding-resolver .unmatched')).toHaveLength(0)
document.dispatchEvent(atom.keymaps.constructor.buildKeyupEvent('a', {target: workspaceElement}))
await etch.getScheduler().getNextUpdatePromise()
expect(workspaceElement.querySelector('.key-binding-resolver .keystroke').textContent).toBe('a ^a')
expect(workspaceElement.querySelectorAll('.key-binding-resolver .used')).toHaveLength(1)
'.never-again': {
'x': 'unmatch-2'
}
})
atom.commands.dispatch(workspaceElement, 'key-binding-resolver:toggle')
document.dispatchEvent(atom.keymaps.constructor.buildKeydownEvent('x', {target: workspaceElement}))
await etch.getScheduler().getNextUpdatePromise()
expect(workspaceElement.querySelector('.key-binding-resolver .keystroke').textContent).toBe('x')
expect(workspaceElement.querySelectorAll('.key-binding-resolver .used')).toHaveLength(1)
expect(workspaceElement.querySelectorAll('.key-binding-resolver .unused')).toHaveLength(1)
expect(workspaceElement.querySelectorAll('.key-binding-resolver .unmatched')).toHaveLength(1)
// It should not render the keyup event data because there is no match
spyOn(etch.getScheduler(), 'updateDocument').andCallThrough()
document.dispatchEvent(atom.keymaps.constructor.buildKeyupEvent('x', {target: workspaceElement}))
expect(etch.getScheduler().updateDocument).not.toHaveBeenCalled()
expect(workspaceElement.querySelector('.key-binding-resolver .keystroke').textContent).toBe('x')
expect(workspaceElement.querySelectorAll('.key-binding-resolver .used')).toHaveLength(1)
expect(workspaceElement.querySelectorAll('.key-binding-resolver .unused')).toHaveLength(1)
expect(workspaceElement.querySelectorAll('.key-binding-resolver .unmatched')).toHaveLength(1)
})
elementAttached() {
// Re-render when the dock is attached to make sure we remeasure sizes defined in CSS.
etch.updateSync(this);
}
this.disposables = new CompositeDisposable();
this.session = session;
// Load the Fit Addon
this.fitAddon = new FitAddon();
this.session.xterm.loadAddon(this.fitAddon);
this.disposables.add(this.fitAddon);
//
// Observe the Session to know when it is destroyed so that we can
// clean up our state (i.e. remove event observers).
//
this.session.onDidDestroy(this.destroy.bind(this));
// TODO: Documentation says this should be set for Atom... Research!
etch.setScheduler(atom.views);
etch.initialize(this);
this.observeResizeEvents();
}
async function activate(state) {
const pns = atom.packages.getAvailablePackageNames();
const packagesProvidingUIServices = ["atom-ide-ui", "linter", "nuclide"];
if (!packagesProvidingUIServices.some(p => pns.includes(p))) {
// tslint:disable-next-line:no-unsafe-any
await require("atom-package-deps").install("atom-typescript", true);
}
// tslint:disable-next-line:no-unsafe-any
require("etch").setScheduler(atom.views);
// tslint:disable-next-line:no-shadowed-variable
const { PluginManager } = require("./pluginManager");
pluginManager = new PluginManager(state);
}
exports.activate = activate;
submit() {
if (!this.state.submitButtonEnabled) {
return;
}
this.state.executing = true;
this.opts.callback && this.opts.callback(this.project);
etch.update(this);
}
constructor(uri, title) {
Etch.initialize(this);
console.log("element", this.element);
this.uri = uri;
this.emitter = new Emitter;
atom.commands.add(this.element, {
'script-runner:copy': () => this.copyToClipboard(),
'script-runner:paste': () => this.pasteToTerminal(),
'script-runner:clear': () => this.clear(),
'script-runner:interrupt': event => this.kill('SIGINT'),
'script-runner:terminate': event => this.kill('SIGTERM'),
'script-runner:kill': event => this.kill('SIGKILL'),
});
if (title == null)
acceptProps ({viewModel}: CommitBoxComponentProps): Promise {
this.viewModel = viewModel
let updatePromise = Promise.resolve()
if (this.element) {
updatePromise = etch.update(this)
} else {
etch.initialize(this)
this.listener = new DOMListener(this.element)
}
if (this.subscriptions) this.subscriptions.dispose()
this.subscriptions = new CompositeDisposable()
this.subscriptions.add(this.listener.add('.git-CommitBox-button', 'click', () => this.commit()))
this.subscriptions.add(atom.commands.add(this.element, {
'git:commit': () => this.commit()
}))
this.subscriptions.add(atom.commands.add('atom-workspace', {
'git:focus-commit-message': () => this.focus(),
'git:focus-commit-button': () => this.focusCommitButton()
}))
async update (props, children) {
if (props.scale != null) this.scale = props.scale
if (props.kind != null) this.kind = props.kind
if (props.mini != null) this.mini = props.mini
this.children = children
await etch.update(this)
this.forceChildrenUpdate()
}