File tree 3 files changed +42
-0
lines changed
3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ ' body.learn-ide.platform-darwin' :
2
+ ' cmd-s' : ' learn-ide:save'
3
+ ' cmd-S' : ' learn-ide:save-as'
4
+ ' cmd-n' : ' tree-view:add-file'
5
+ ' cmd-o' : ' learn-ide:file-open'
6
+ ' cmd-O' : ' learn-ide:add-project'
7
+ ' cmd-alt-s' : ' learn-ide:save-all'
8
+
9
+ ' body.learn-ide.platform-win32' :
10
+ ' ctrl-s' : ' learn-ide:save'
11
+ ' ctrl-S' : ' learn-ide:save-as'
12
+ ' ctrl-n' : ' tree-view:add-file'
13
+ ' ctrl-o' : ' learn-ide:file-open'
14
+ ' ctrl-alt-o' : ' learn-ide:add-project'
15
+
16
+ ' body.learn-ide.platform-linux' :
17
+ ' ctrl-s' : ' learn-ide:save'
18
+ ' ctrl-S' : ' learn-ide:save-as'
19
+ ' ctrl-n' : ' tree-view:add-file'
20
+ ' ctrl-o' : ' learn-ide:file-open'
21
+ ' ctrl-alt-o' : ' learn-ide:add-project'
22
+
1
23
' .platform-darwin' :
2
24
' cmd-\\ ' : ' tree-view:toggle'
3
25
' cmd-k cmd-b' : ' tree-view:toggle'
Original file line number Diff line number Diff line change @@ -105,6 +105,9 @@ module.exports = helper =
105
105
selectedPath : ->
106
106
@ treeView ()? .selectedPath
107
107
108
+ observeTextEditors : (callback ) ->
109
+ atom .workspace .observeTextEditors (callback)
110
+
108
111
findTextEditorByElement : (element ) ->
109
112
atom .workspace .getTextEditors ().find (editor) ->
110
113
editor .element is element
@@ -113,6 +116,9 @@ module.exports = helper =
113
116
atom .workspace .getTextEditors ().find (editor) ->
114
117
editor .getPath () is path
115
118
119
+ findOrCreateBuffer : (path ) ->
120
+ atom .project .bufferForPath (path)
121
+
116
122
saveEditor : (path ) ->
117
123
textEditor = @ findTextEditorByPath (path)
118
124
Original file line number Diff line number Diff line change @@ -78,6 +78,16 @@ importLocalPaths = (localPaths) ->
78
78
79
79
nsync .save (newPath, data)
80
80
81
+ onEditorSave = ({path}) ->
82
+ node = nsync .getNode (path)
83
+
84
+ node .determineSync ().then (shouldSync) ->
85
+ if shouldSync
86
+ atomHelper .findOrCreateBuffer (path).then (textBuffer) ->
87
+ text = convertEOL (textBuffer .getText ())
88
+ content = new Buffer (text).toString (' base64' )
89
+ nsync .save (node .path , content)
90
+
81
91
module .exports = helper = (activationState ) ->
82
92
disposables = new CompositeDisposable
83
93
@@ -129,6 +139,10 @@ module.exports = helper = (activationState) ->
129
139
disposables .add nsync .onDidUpdate (path) ->
130
140
atomHelper .saveEditor (path)
131
141
142
+ disposables .add atomHelper .observeTextEditors (editor) ->
143
+ disposables .add editor .onDidSave (e) ->
144
+ onEditorSave (e)
145
+
132
146
atomHelper .getToken ().then (token) ->
133
147
nsync .configure
134
148
expansionState : activationState .directoryExpansionStates
You can’t perform that action at this time.
0 commit comments