Skip to content
This repository has been archived by the owner on Nov 29, 2020. It is now read-only.

Commit

Permalink
fix issue #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Qusic authored and Qusic committed Apr 19, 2015
1 parent cb2e8c4 commit 27eb273
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/ycm-provider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,28 @@ module.exports =
getSuggestions: ({editor, bufferPosition, scopeDescriptor}) ->
Promise.resolve()
.then () ->
filepath = editor.buffer.file?.path
filepath = editor.getPath()
contents = editor.getText()
filetypes = scopeDescriptor.getScopesArray().map (scope) -> scope.split('.').pop()
if filepath?
return filepath
return [filepath, contents, filetypes]
else
return new Promise (fulfill, reject) ->
filepath = path.resolve os.tmpdir(), "AtomYcmBuffer-#{editor.id}"
fs.writeFile filepath, editor.buffer.cachedText, encoding: 'utf8', (error) ->
fs.writeFile filepath, contents, encoding: 'utf8', (error) ->
unless error?
fulfill filepath
fulfill [filepath, contents, filetypes]
else
reject error
.then (filepath) ->
.then ([filepath, contents, filetypes]) ->
parameters =
line_num: bufferPosition.row + 1
column_num: bufferPosition.column + 1
filepath: filepath
file_data: {}
parameters.file_data[parameters.filepath] =
filetypes: scopeDescriptor.scopes.map (scope) -> scope.split('.').pop()
contents: editor.buffer.cachedText
parameters.file_data[filepath] =
contents: contents
filetypes: filetypes
return parameters
.then (parameters) =>
@handler.request('POST', 'completions', parameters).then (response) ->
Expand Down

0 comments on commit 27eb273

Please sign in to comment.