This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All of these changes we're made by `prettier` automatically
- Loading branch information
Showing
19 changed files
with
1,978 additions
and
1,436 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,82 @@ | ||
const SnippetHistoryProvider = require('./snippet-history-provider') | ||
const SnippetHistoryProvider = require('./snippet-history-provider'); | ||
|
||
class EditorStore { | ||
constructor (editor) { | ||
this.editor = editor | ||
this.buffer = this.editor.getBuffer() | ||
this.observer = null | ||
this.checkpoint = null | ||
this.expansions = [] | ||
this.existingHistoryProvider = null | ||
constructor(editor) { | ||
this.editor = editor; | ||
this.buffer = this.editor.getBuffer(); | ||
this.observer = null; | ||
this.checkpoint = null; | ||
this.expansions = []; | ||
this.existingHistoryProvider = null; | ||
} | ||
|
||
getExpansions () { | ||
return this.expansions | ||
getExpansions() { | ||
return this.expansions; | ||
} | ||
|
||
setExpansions (list) { | ||
this.expansions = list | ||
setExpansions(list) { | ||
this.expansions = list; | ||
} | ||
|
||
clearExpansions () { | ||
this.expansions = [] | ||
clearExpansions() { | ||
this.expansions = []; | ||
} | ||
|
||
addExpansion (snippetExpansion) { | ||
this.expansions.push(snippetExpansion) | ||
addExpansion(snippetExpansion) { | ||
this.expansions.push(snippetExpansion); | ||
} | ||
|
||
observeHistory (delegates) { | ||
observeHistory(delegates) { | ||
if (this.existingHistoryProvider == null) { | ||
this.existingHistoryProvider = this.buffer.historyProvider | ||
this.existingHistoryProvider = this.buffer.historyProvider; | ||
} | ||
|
||
const newProvider = SnippetHistoryProvider(this.existingHistoryProvider, delegates) | ||
this.buffer.setHistoryProvider(newProvider) | ||
const newProvider = SnippetHistoryProvider( | ||
this.existingHistoryProvider, | ||
delegates | ||
); | ||
this.buffer.setHistoryProvider(newProvider); | ||
} | ||
|
||
stopObservingHistory (editor) { | ||
if (this.existingHistoryProvider == null) { return } | ||
this.buffer.setHistoryProvider(this.existingHistoryProvider) | ||
this.existingHistoryProvider = null | ||
stopObservingHistory(editor) { | ||
if (this.existingHistoryProvider == null) { | ||
return; | ||
} | ||
this.buffer.setHistoryProvider(this.existingHistoryProvider); | ||
this.existingHistoryProvider = null; | ||
} | ||
|
||
observe (callback) { | ||
if (this.observer != null) { this.observer.dispose() } | ||
this.observer = this.buffer.onDidChangeText(callback) | ||
observe(callback) { | ||
if (this.observer != null) { | ||
this.observer.dispose(); | ||
} | ||
this.observer = this.buffer.onDidChangeText(callback); | ||
} | ||
|
||
stopObserving () { | ||
if (this.observer == null) { return false } | ||
this.observer.dispose() | ||
this.observer = null | ||
return true | ||
stopObserving() { | ||
if (this.observer == null) { | ||
return false; | ||
} | ||
this.observer.dispose(); | ||
this.observer = null; | ||
return true; | ||
} | ||
|
||
makeCheckpoint () { | ||
const existing = this.checkpoint | ||
makeCheckpoint() { | ||
const existing = this.checkpoint; | ||
if (existing) { | ||
this.buffer.groupChangesSinceCheckpoint(existing) | ||
this.buffer.groupChangesSinceCheckpoint(existing); | ||
} | ||
this.checkpoint = this.buffer.createCheckpoint() | ||
this.checkpoint = this.buffer.createCheckpoint(); | ||
} | ||
} | ||
|
||
EditorStore.store = new WeakMap() | ||
EditorStore.store = new WeakMap(); | ||
EditorStore.findOrCreate = function (editor) { | ||
if (!this.store.has(editor)) { | ||
this.store.set(editor, new EditorStore(editor)) | ||
this.store.set(editor, new EditorStore(editor)); | ||
} | ||
return this.store.get(editor) | ||
} | ||
return this.store.get(editor); | ||
}; | ||
|
||
module.exports = EditorStore | ||
module.exports = EditorStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
/** @babel */ | ||
|
||
import path from 'path' | ||
import path from 'path'; | ||
|
||
export function getPackageRoot() { | ||
const {resourcePath} = atom.getLoadSettings() | ||
const currentFileWasRequiredFromSnapshot = !path.isAbsolute(__dirname) | ||
const { resourcePath } = atom.getLoadSettings(); | ||
const currentFileWasRequiredFromSnapshot = !path.isAbsolute(__dirname); | ||
if (currentFileWasRequiredFromSnapshot) { | ||
return path.join(resourcePath, 'node_modules', 'snippets') | ||
return path.join(resourcePath, 'node_modules', 'snippets'); | ||
} else { | ||
return path.resolve(__dirname, '..') | ||
return path.resolve(__dirname, '..'); | ||
} | ||
} |
Oops, something went wrong.