Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Prepare for editor.save becoming async (#64)
Browse files Browse the repository at this point in the history
* Prepare for `editor.save` becoming async

Fixes #63

This fix should be both backcompatible and forwardcompatible, as returning something that's not a promise from a promise callback will resolve immediately, whereas returning a promise will wait for the promise, so it should do the right thing whether save is sync or async.

* Install libstdc++6 for electron

* Disable testing beta atom

* Need to return the promise from `getCompletions` -.-
  • Loading branch information
rictic committed Jun 16, 2017
1 parent ebba173 commit c057503
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ cache:
- node_modules

script:
- sudo apt-get install libstdc++6
- npm run build && rm -r node_modules
- curl -s -O https://raw.githubusercontent.com/atom/ci/master/build-package.sh
- chmod u+x build-package.sh
- ./build-package.sh

env:
matrix:
- ATOM_CHANNEL=beta
21 changes: 12 additions & 9 deletions spec/auto-completer-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ describe('Autocompleter', () => {
const LAST_LINE_IN_TEMPLATE = 12;

const getCompletions = () => {
editor.save();
const cursor = editor.getLastCursor();
const start = cursor.getBeginningOfCurrentWordBufferPosition();
const end = cursor.getBufferPosition();
return provider.getSuggestions({
editor: editor,
bufferPosition: end,
scopeDescriptor: cursor.getScopeDescriptor(),
prefix: editor.getTextInRange([start, end])
return Promise.resolve().then(() => {
return editor.save();
}).then(() => {
const cursor = editor.getLastCursor();
const start = cursor.getBeginningOfCurrentWordBufferPosition();
const end = cursor.getBufferPosition();
return provider.getSuggestions({
editor: editor,
bufferPosition: end,
scopeDescriptor: cursor.getScopeDescriptor(),
prefix: editor.getTextInRange([start, end])
});
}).catch(e => {
console.error(e);
throw e;
Expand Down

0 comments on commit c057503

Please sign in to comment.