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

Commit

Permalink
Added hotkey activation back in, renamed options, added warning when …
Browse files Browse the repository at this point in the history
…using autosave
  • Loading branch information
saschagehlich committed Apr 10, 2014
1 parent a0bd620 commit 714e485
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 11 deletions.
3 changes: 3 additions & 0 deletions keymaps/autocomplete-plus.cson
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
".autocomplete-plus input.hidden-input":
"tab": "autocomplete-plus:confirm"

".editor":
"ctrl-shift-space": "autocomplete-plus:activate"
6 changes: 4 additions & 2 deletions lib/autocomplete-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class AutocompleteView extends SimpleSelectListView
@handleEvents()
@setCurrentBuffer @editor.getBuffer()

@subscribeToCommand @editorView, "autocomplete-plus:activate", @runAutocompletion

###
* Checks whether the current file is blacklisted
* @return {Boolean}
Expand Down Expand Up @@ -166,7 +168,7 @@ class AutocompleteView extends SimpleSelectListView
* @private
###
contentsModified: =>
delay = parseInt(atom.config.get "autocomplete-plus.completionDelay")
delay = parseInt(atom.config.get "autocomplete-plus.autoActivationDelay")
if @delayTimeout
clearTimeout @delayTimeout

Expand Down Expand Up @@ -203,7 +205,7 @@ class AutocompleteView extends SimpleSelectListView
newLine = e.newText is "\n"
@addLastWordToList newLine

if e.newText.length is 1
if e.newText.length is 1 and atom.config.get "autocomplete-plus.enableAutoActivation"
@contentsModified()
else
@cancel()
Expand Down
15 changes: 14 additions & 1 deletion lib/autocomplete.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module.exports =
configDefaults:
includeCompletionsFromAllBuffers: false
fileBlacklist: ".*, *.md"
completionDelay: 100
enableAutoActivation: true
autoActivationDelay: 100

autocompleteViews: []
editorSubscription: null
Expand All @@ -14,6 +15,18 @@ module.exports =
* Creates AutocompleteView instances for all active and future editors
###
activate: ->
# If both autosave and autocomplete+'s auto-activation feature are enabled,
# disable the auto-activation
if atom.packages.isPackageLoaded("autosave") and
atom.config.get("autocomplete-plus.enableAutoActivation")
atom.config.set "autocomplete-plus.enableAutoActivation", false

alert """Warning from autocomplete+:
autocomplete+ is not compatible with the autosave package when the auto-activation feature is enabled. Therefore, auto-activation has been disabled.
autocomplete+ can now only be triggered using the keyboard shortcut `ctrl+space`."""

@editorSubscription = atom.workspaceView.eachEditorView (editor) =>
if editor.attached and not editor.mini
autocompleteView = new AutocompleteView(editor)
Expand Down
4 changes: 2 additions & 2 deletions spec/autocomplete-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ describe "Autocomplete", ->
atom.workspaceView.simulateDomAttachment()

# Set to live completion
atom.config.set "autocomplete-plus.liveCompletion", true
atom.config.set "autocomplete-plus.enableAutoActivation", true

# Set the completion delay
completionDelay = 100
atom.config.set "autocomplete-plus.completionDelay", completionDelay
atom.config.set "autocomplete-plus.autoActivationDelay", completionDelay
completionDelay += 100 # Rendering delay

# Spy on AutocompleteView#initialize
Expand Down
4 changes: 2 additions & 2 deletions spec/issues/11-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ describe "Autocomplete", ->
atom.workspaceView.simulateDomAttachment()

# Set to live completion
atom.config.set "autocomplete-plus.liveCompletion", true
atom.config.set "autocomplete-plus.enableAutoActivation", true

# Set the completion delay
completionDelay = 100
atom.config.set "autocomplete-plus.completionDelay", completionDelay
atom.config.set "autocomplete-plus.autoActivationDelay", completionDelay
completionDelay += 100 # Rendering delay

# Activate the package
Expand Down
4 changes: 2 additions & 2 deletions spec/issues/15-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ describe "Autocomplete", ->
atom.workspaceView.simulateDomAttachment()

# Set to live completion
atom.config.set "autocomplete-plus.liveCompletion", true
atom.config.set "autocomplete-plus.enableAutoActivation", true

# Set the completion delay
completionDelay = 100
atom.config.set "autocomplete-plus.completionDelay", completionDelay
atom.config.set "autocomplete-plus.autoActivationDelay", completionDelay
completionDelay += 100 # Rendering delay

# Activate the package
Expand Down
4 changes: 2 additions & 2 deletions spec/issues/23-25-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ describe "Autocomplete", ->
atom.workspaceView.simulateDomAttachment()

# Set to live completion
atom.config.set "autocomplete-plus.liveCompletion", true
atom.config.set "autocomplete-plus.enableAutoActivation", true

# Set the completion delay
completionDelay = 100
atom.config.set "autocomplete-plus.completionDelay", completionDelay
atom.config.set "autocomplete-plus.autoActivationDelay", completionDelay
completionDelay += 100 # Rendering delay

# Activate the package
Expand Down

0 comments on commit 714e485

Please sign in to comment.