Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit e7d8455

Browse files
committed
implement missing functionality from master
i made some false assumptions about how stuff worked But now this should be onpar with master, kinda The babel stuff will be removed once i clean this up
1 parent f0a1ff6 commit e7d8455

18 files changed

+1261
-1084
lines changed

available-snippets-view.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const SelectListView = require('atom-select-list')
2+
3+
module.exports = class AvailableSnippetsView extends SelectListView {
4+
constructor (snippets, editor) {
5+
super({
6+
items: Object.entries(snippets.snippetsByScopes()
7+
.getPropertyValue(editor.getRootScopeDescriptor().getScopeChain())),
8+
filterKeyForItem: ([name, { prefix }]) => prefix + name,
9+
elementForItem: ([name, { prefix }]) => {
10+
const li = document.createElement('li')
11+
li.classList.add('two-lines')
12+
13+
const primaryLine = document.createElement('div')
14+
primaryLine.classList.add('primary-line')
15+
primaryLine.textContent = prefix
16+
li.appendChild(primaryLine)
17+
18+
const secondaryLine = document.createElement('div')
19+
secondaryLine.classList.add('secondary-line')
20+
secondaryLine.textContent = name
21+
li.appendChild(secondaryLine)
22+
23+
return li
24+
},
25+
emptyMessage: 'No snippets defined for this Grammar.',
26+
itemsClassList: ['available-snippets'],
27+
didConfirmSelection: ([, { body }]) => {
28+
this.destroy()
29+
editor.getCursors().forEach(cursor =>
30+
snippets.parse(body).expand({ editor, cursor }))
31+
},
32+
didConfirmEmptySelection: () => this.destroy(),
33+
didCancelSelection: () => this.destroy()
34+
})
35+
36+
const panel = atom.workspace.addModalPanel({ item: this })
37+
this.disposables.add(
38+
// Register cleanup disposables to be called on desctruction
39+
{ dispose: () => document.activeElement.focus },
40+
{ dispose: () => { panel.destroy() } })
41+
42+
this.focus()
43+
}
44+
}

babel.config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"plugins": [
3+
"@babel/plugin-proposal-class-properties",
4+
"@babel/plugin-proposal-private-methods"
5+
]
6+
}

constructs/babel.config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"plugins": [
3+
"@babel/plugin-proposal-class-properties",
4+
"@babel/plugin-proposal-private-methods"
5+
]
6+
}

constructs/construct.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,29 @@ module.exports = class Construct {
33
this.identifier = identifier
44
}
55

6-
insert (cursor, value) {
7-
return cursor.editor.getBuffer().insert(cursor.getBufferPosition(), value)
6+
expand () {}
7+
8+
insert (editor, cursor, value) {
9+
return editor.getBuffer().insert(cursor.getBufferPosition(), value)
810
}
911

10-
activate (mirror, cursor, stop) {
12+
activate (editor, cursor, stop, mirror) {
1113
if (mirror === stop) {
12-
cursor.selection.setBufferRange(stop.getRange())
14+
cursor.selection.setBufferRange(stop.getBufferRange())
1315
const subscription = cursor.onDidChangePosition(({ newBufferPosition }) => {
14-
if (!stop.getRange().containsPoint(newBufferPosition)) {
16+
if (!stop.getBufferRange().containsPoint(newBufferPosition)) {
1517
stop.destroy()
1618
subscription.dispose()
1719
}
1820
})
1921
} else {
20-
cursor.editor.decorateMarker(mirror, { type: 'highlight' })
22+
editor.decorateMarker(mirror, { type: 'highlight' })
2123
stop.onDidDestroy(() => mirror.destroy())
2224
}
2325
}
2426

2527
mark ({ tabstops, start, end = start, exclusive = true, construct = this }) {
26-
tabstops.markRange({ start, end }, { exclusive }).setProperties({ construct })
28+
tabstops.markBufferRange({ start, end }, { exclusive }).setProperties({ construct })
2729
}
2830

2931
toString () {

0 commit comments

Comments
 (0)