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

Commit

Permalink
Don't fuzzy provider tokens when editor.largeFileMode is on
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Scandurra committed Oct 12, 2016
1 parent 4b2e373 commit 93a9fe6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/fuzzy-provider.coffee
Expand Up @@ -56,10 +56,11 @@ class FuzzyProvider

# Subscribe to buffer events:
@currentEditorSubscriptions = new CompositeDisposable
@currentEditorSubscriptions.add @buffer.onDidSave(@bufferSaved)
@currentEditorSubscriptions.add @buffer.onWillChange(@bufferWillChange)
@currentEditorSubscriptions.add @buffer.onDidChange(@bufferDidChange)
@buildWordList()
unless @editor.largeFileMode
@currentEditorSubscriptions.add @buffer.onDidSave(@bufferSaved)
@currentEditorSubscriptions.add @buffer.onWillChange(@bufferWillChange)
@currentEditorSubscriptions.add @buffer.onDidChange(@bufferDidChange)
@buildWordList()

paneItemIsValid: (paneItem) ->
# TODO: remove conditional when `isTextEditor` is shipped.
Expand Down
23 changes: 23 additions & 0 deletions spec/fuzzy-provider-spec.coffee
Expand Up @@ -2,6 +2,8 @@ describe 'FuzzyProvider', ->
[completionDelay, editor, mainModule, autocompleteManager] = []

beforeEach ->
atom.config.set('autocomplete-plus.includeCompletionsFromAllBuffers', false)

# Set to live completion
atom.config.set('autocomplete-plus.enableAutoActivation', true)
atom.config.set('autocomplete-plus.defaultProvider', 'Fuzzy')
Expand Down Expand Up @@ -37,6 +39,27 @@ describe 'FuzzyProvider', ->
editor.insertText('somethingNew')
expect(provider.tokenList.getToken('somethingNew')).toBe 'somethingNew'

describe "when `editor.largeFileMode` is true", ->
it "doesn't add words to the wordlist when the buffer changes", ->
provider = autocompleteManager.providerManager.defaultProvider
coffeeEditor = null

waitsForPromise ->
atom.packages.activatePackage("language-coffee-script")

waitsForPromise ->
atom.workspace.open('sample.coffee').then (e) ->
coffeeEditor = e
coffeeEditor.largeFileMode = true

runs ->
advanceClock(provider.deferBuildWordListInterval)
expect(provider.tokenList.getToken('SomeModule')).toBeUndefined()

coffeeEditor.getBuffer().insert([0, 0], 'abc')
advanceClock(provider.deferBuildWordListInterval)
expect(provider.tokenList.getToken('abcSomeModule')).toBeUndefined()

it 'removes words that are no longer in the buffer', ->
editor.moveToBottom()
editor.moveToBeginningOfLine()
Expand Down

0 comments on commit 93a9fe6

Please sign in to comment.