1
- const { CompositeDisposable, Range, Point} = require ( 'atom' )
1
+ const { CompositeDisposable, Range, Point } = require ( 'atom' )
2
2
3
3
module . exports = class SnippetExpansion {
4
- constructor ( snippet , editor , cursor , snippets ) {
4
+ constructor ( snippet , editor , cursor , snippets ) {
5
5
this . settingTabStop = false
6
6
this . isIgnoringBufferChanges = false
7
7
this . onUndoOrRedo = this . onUndoOrRedo . bind ( this )
8
8
this . snippet = snippet
9
9
this . editor = editor
10
10
this . cursor = cursor
11
11
this . snippets = snippets
12
- this . subscriptions = new CompositeDisposable
12
+ this . subscriptions = new CompositeDisposable ( )
13
13
this . tabStopMarkers = [ ]
14
14
this . selections = [ this . cursor . selection ]
15
15
16
16
const startPosition = this . cursor . selection . getBufferRange ( ) . start
17
- let { body, tabStopList} = this . snippet
17
+ let { body, tabStopList } = this . snippet
18
18
let tabStops = tabStopList . toArray ( )
19
19
20
- let indent = this . editor . lineTextForBufferRow ( startPosition . row ) . match ( / ^ \s * / ) [ 0 ]
20
+ const indent = this . editor . lineTextForBufferRow ( startPosition . row ) . match ( / ^ \s * / ) [ 0 ]
21
21
if ( this . snippet . lineCount > 1 && indent ) {
22
22
// Add proper leading indentation to the snippet
23
23
body = body . replace ( / \n / g, `\n${ indent } ` )
@@ -28,7 +28,7 @@ module.exports = class SnippetExpansion {
28
28
this . editor . transact ( ( ) => {
29
29
this . ignoringBufferChanges ( ( ) => {
30
30
this . editor . transact ( ( ) => {
31
- const newRange = this . cursor . selection . insertText ( body , { autoIndent : false } )
31
+ const newRange = this . cursor . selection . insertText ( body , { autoIndent : false } )
32
32
if ( this . snippet . tabStopList . length > 0 ) {
33
33
this . subscriptions . add ( this . cursor . onDidChangePosition ( event => this . cursorMoved ( event ) ) )
34
34
this . subscriptions . add ( this . cursor . onDidDestroy ( ( ) => this . cursorDestroyed ( ) ) )
@@ -47,7 +47,7 @@ module.exports = class SnippetExpansion {
47
47
this . isUndoingOrRedoing = true
48
48
}
49
49
50
- cursorMoved ( { oldBufferPosition, newBufferPosition, textChanged} ) {
50
+ cursorMoved ( { oldBufferPosition, newBufferPosition, textChanged } ) {
51
51
if ( this . settingTabStop || textChanged ) { return }
52
52
const itemWithCursor = this . tabStopMarkers [ this . tabStopIndex ] . find ( item => item . marker . getBufferRange ( ) . containsPoint ( newBufferPosition ) )
53
53
@@ -95,7 +95,7 @@ module.exports = class SnippetExpansion {
95
95
96
96
this . ignoringBufferChanges ( ( ) => {
97
97
for ( const item of items ) {
98
- const { marker, insertion} = item
98
+ const { marker, insertion } = item
99
99
var range = marker . getBufferRange ( )
100
100
101
101
// Don't transform mirrored tab stops. They have their own cursors, so
@@ -115,14 +115,14 @@ module.exports = class SnippetExpansion {
115
115
116
116
placeTabStopMarkers ( startPosition , tabStops ) {
117
117
for ( const tabStop of tabStops ) {
118
- const { insertions} = tabStop
118
+ const { insertions } = tabStop
119
119
const markers = [ ]
120
120
121
121
if ( ! tabStop . isValid ( ) ) { continue }
122
122
123
123
for ( const insertion of insertions ) {
124
- const { range} = insertion
125
- const { start, end} = range
124
+ const { range } = insertion
125
+ const { start, end } = range
126
126
const marker = this . getMarkerLayer ( this . editor ) . markBufferRange ( [
127
127
startPosition . traverse ( start ) ,
128
128
startPosition . traverse ( end )
@@ -178,7 +178,7 @@ module.exports = class SnippetExpansion {
178
178
const ranges = [ ]
179
179
this . hasTransforms = false
180
180
for ( const item of items ) {
181
- const { marker, insertion} = item
181
+ const { marker, insertion } = item
182
182
if ( marker . isDestroyed ( ) ) { continue }
183
183
if ( ! marker . isValid ( ) ) { continue }
184
184
if ( insertion . isTransformation ( ) ) {
@@ -217,7 +217,7 @@ module.exports = class SnippetExpansion {
217
217
if ( this . tabStopMarkers . length === 0 ) { return }
218
218
const items = this . tabStopMarkers [ this . tabStopMarkers . length - 1 ]
219
219
if ( items . length === 0 ) { return }
220
- const { marker : lastMarker } = items [ items . length - 1 ]
220
+ const { marker : lastMarker } = items [ items . length - 1 ]
221
221
if ( lastMarker . isDestroyed ( ) ) {
222
222
return false
223
223
} else {
0 commit comments