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

Commit 0cd31f1

Browse files
committed
some improvements
1 parent 10440e6 commit 0cd31f1

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

lib/snippet-injector.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,6 @@ export default {
127127
var selection = atom.workspace.getActiveTextEditor().getSelectedText();
128128
var grammar = atom.workspace.getActiveTextEditor().getGrammar().name;
129129
var storage = this.storage;
130-
var uid = Util.generateUID({
131-
unique: true,
132-
tester: storage.testFile,
133-
timeout: 100,
134-
length: 20,
135-
prefix: 'sn',
136-
insertstring: 'SNIPPET'
137-
});
138130
const inputPrompt = Util.promptUser({
139131
placeholder: 'Enter snippet title',
140132
btnconfirm: 'Save snippet',
@@ -143,10 +135,9 @@ export default {
143135
if(Util.isset(text,'string')) {
144136
var result = storage.store(new Snippet({
145137
title: text,
146-
tags: new Array(),
147138
content: selection,
148139
lang: grammar,
149-
uid: uid
140+
version: Util.getPackageVersion()
150141
}));
151142
if(result) {
152143
atom.notifications.addSuccess('Snippet "'+text+'" was saved successfully.', null);

lib/snippet.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use babel';
22

33
import Util from './util.js';
4+
import Storage from './storage.js';
45
const os = require('os');
56

67
const lastUpdate = '1.1.8';
@@ -11,7 +12,14 @@ export default class Snippet {
1112
title = '';
1213
tags = new Array();
1314
lang = '';
14-
uid = Date.now().toString();
15+
uid = Util.generateUID({
16+
unique: true,
17+
tester: Storage.testFile,
18+
timeout: 100,
19+
length: 20,
20+
prefix: 'sn',
21+
insertstring: 'SNIPPET'
22+
});
1523
version = undefined;
1624
author = os.userInfo().username;
1725

lib/storage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export default class Storage {
113113
}
114114
}
115115

116-
testFile(uid) {
116+
static testFile(uid) {
117117
if(this.dir === '') {
118118
throw new TypeError('Storage directory has not been initialized.');
119119
} else {

0 commit comments

Comments
 (0)