|
1 | | -const SnippetHistoryProvider = require('./snippet-history-provider') |
| 1 | +const SnippetHistoryProvider = require('./snippet-history-provider'); |
2 | 2 |
|
3 | 3 | class EditorStore { |
4 | | - constructor (editor) { |
5 | | - this.editor = editor |
6 | | - this.buffer = this.editor.getBuffer() |
7 | | - this.observer = null |
8 | | - this.checkpoint = null |
9 | | - this.expansions = [] |
10 | | - this.existingHistoryProvider = null |
| 4 | + constructor(editor) { |
| 5 | + this.editor = editor; |
| 6 | + this.buffer = this.editor.getBuffer(); |
| 7 | + this.observer = null; |
| 8 | + this.checkpoint = null; |
| 9 | + this.expansions = []; |
| 10 | + this.existingHistoryProvider = null; |
11 | 11 | } |
12 | 12 |
|
13 | | - getExpansions () { |
14 | | - return this.expansions |
| 13 | + getExpansions() { |
| 14 | + return this.expansions; |
15 | 15 | } |
16 | 16 |
|
17 | | - setExpansions (list) { |
18 | | - this.expansions = list |
| 17 | + setExpansions(list) { |
| 18 | + this.expansions = list; |
19 | 19 | } |
20 | 20 |
|
21 | | - clearExpansions () { |
22 | | - this.expansions = [] |
| 21 | + clearExpansions() { |
| 22 | + this.expansions = []; |
23 | 23 | } |
24 | 24 |
|
25 | | - addExpansion (snippetExpansion) { |
26 | | - this.expansions.push(snippetExpansion) |
| 25 | + addExpansion(snippetExpansion) { |
| 26 | + this.expansions.push(snippetExpansion); |
27 | 27 | } |
28 | 28 |
|
29 | | - observeHistory (delegates) { |
| 29 | + observeHistory(delegates) { |
30 | 30 | if (this.existingHistoryProvider == null) { |
31 | | - this.existingHistoryProvider = this.buffer.historyProvider |
| 31 | + this.existingHistoryProvider = this.buffer.historyProvider; |
32 | 32 | } |
33 | 33 |
|
34 | | - const newProvider = SnippetHistoryProvider(this.existingHistoryProvider, delegates) |
35 | | - this.buffer.setHistoryProvider(newProvider) |
| 34 | + const newProvider = SnippetHistoryProvider( |
| 35 | + this.existingHistoryProvider, |
| 36 | + delegates |
| 37 | + ); |
| 38 | + this.buffer.setHistoryProvider(newProvider); |
36 | 39 | } |
37 | 40 |
|
38 | | - stopObservingHistory (editor) { |
39 | | - if (this.existingHistoryProvider == null) { return } |
40 | | - this.buffer.setHistoryProvider(this.existingHistoryProvider) |
41 | | - this.existingHistoryProvider = null |
| 41 | + stopObservingHistory(editor) { |
| 42 | + if (this.existingHistoryProvider == null) { |
| 43 | + return; |
| 44 | + } |
| 45 | + this.buffer.setHistoryProvider(this.existingHistoryProvider); |
| 46 | + this.existingHistoryProvider = null; |
42 | 47 | } |
43 | 48 |
|
44 | | - observe (callback) { |
45 | | - if (this.observer != null) { this.observer.dispose() } |
46 | | - this.observer = this.buffer.onDidChangeText(callback) |
| 49 | + observe(callback) { |
| 50 | + if (this.observer != null) { |
| 51 | + this.observer.dispose(); |
| 52 | + } |
| 53 | + this.observer = this.buffer.onDidChangeText(callback); |
47 | 54 | } |
48 | 55 |
|
49 | | - stopObserving () { |
50 | | - if (this.observer == null) { return false } |
51 | | - this.observer.dispose() |
52 | | - this.observer = null |
53 | | - return true |
| 56 | + stopObserving() { |
| 57 | + if (this.observer == null) { |
| 58 | + return false; |
| 59 | + } |
| 60 | + this.observer.dispose(); |
| 61 | + this.observer = null; |
| 62 | + return true; |
54 | 63 | } |
55 | 64 |
|
56 | | - makeCheckpoint () { |
57 | | - const existing = this.checkpoint |
| 65 | + makeCheckpoint() { |
| 66 | + const existing = this.checkpoint; |
58 | 67 | if (existing) { |
59 | | - this.buffer.groupChangesSinceCheckpoint(existing) |
| 68 | + this.buffer.groupChangesSinceCheckpoint(existing); |
60 | 69 | } |
61 | | - this.checkpoint = this.buffer.createCheckpoint() |
| 70 | + this.checkpoint = this.buffer.createCheckpoint(); |
62 | 71 | } |
63 | 72 | } |
64 | 73 |
|
65 | | -EditorStore.store = new WeakMap() |
| 74 | +EditorStore.store = new WeakMap(); |
66 | 75 | EditorStore.findOrCreate = function (editor) { |
67 | 76 | if (!this.store.has(editor)) { |
68 | | - this.store.set(editor, new EditorStore(editor)) |
| 77 | + this.store.set(editor, new EditorStore(editor)); |
69 | 78 | } |
70 | | - return this.store.get(editor) |
71 | | -} |
| 79 | + return this.store.get(editor); |
| 80 | +}; |
72 | 81 |
|
73 | | -module.exports = EditorStore |
| 82 | +module.exports = EditorStore; |
0 commit comments