diff --git a/lib/bracket-matcher.coffee b/lib/bracket-matcher.coffee index 7e0ad8c..7326026 100644 --- a/lib/bracket-matcher.coffee +++ b/lib/bracket-matcher.coffee @@ -24,7 +24,6 @@ class BracketMatcher "‹": "›" toggleQuotes: (includeSmartQuotes) -> - return if @pairedCharacters? and includeSmartQuotes is (@pairedCharacters isnt @defaultPairs) if includeSmartQuotes @pairedCharacters = _.extend({}, @defaultPairs, @smartQuotePairs) else diff --git a/spec/bracket-matcher-spec.coffee b/spec/bracket-matcher-spec.coffee index 34f95cf..e896597 100644 --- a/spec/bracket-matcher-spec.coffee +++ b/spec/bracket-matcher-spec.coffee @@ -666,7 +666,7 @@ describe "bracket matching", -> expect(editor.getSelectedBufferRange()).toEqual [[0, 1], [0, 5]] expect(editor.getLastSelection().isReversed()).toBeTruthy() - describe "when the bracket-matcher.wrapSelectionsInBrackets is falsy", -> + describe "when the bracket-matcher.wrapSelectionsInBrackets is falsy globally", -> it "does not wrap the selection in brackets", -> atom.config.set('bracket-matcher.wrapSelectionsInBrackets', false) editor.setText 'text' @@ -677,6 +677,18 @@ describe "bracket matching", -> expect(buffer.getText()).toBe '(' expect(editor.getSelectedBufferRange()).toEqual [[0, 1], [0, 1]] + describe "when the bracket-matcher.wrapSelectionsInBrackets is falsy in scope", -> + it "does not wrap the selection in brackets", -> + atom.config.set('bracket-matcher.wrapSelectionsInBrackets', true) + atom.config.set('bracket-matcher.wrapSelectionsInBrackets', false, scopeSelector: '.source.js') + editor.setText 'text' + editor.moveToBottom() + editor.selectToTop() + editor.selectAll() + editor.insertText '(' + expect(buffer.getText()).toBe '(' + expect(editor.getSelectedBufferRange()).toEqual [[0, 1], [0, 1]] + describe "when there is text selected on multiple lines", -> it "wraps the selection with brackets", -> editor.insertText 'text\nabcd' @@ -921,7 +933,7 @@ describe "bracket matching", -> editor.backspace() expect(buffer.lineForRow(0)).toBe "" - it "does not delete end bracket even if it directly precedes a begin bracket if autocomplete is turned off", -> + it "does not delete end bracket even if it directly precedes a begin bracket if autocomplete is turned off globally", -> atom.config.set 'bracket-matcher.autocompleteBrackets', false buffer.setText("") editor.setCursorBufferPosition([0, 0]) @@ -933,6 +945,19 @@ describe "bracket matching", -> editor.backspace() expect(buffer.lineForRow(0)).toBe "}" + it "does not delete end bracket even if it directly precedes a begin bracket if autocomplete is turned off in scope", -> + atom.config.set 'bracket-matcher.autocompleteBrackets', true + atom.config.set 'bracket-matcher.autocompleteBrackets', false, scopeSelector: '.source.js' + buffer.setText("") + editor.setCursorBufferPosition([0, 0]) + editor.insertText "{" + expect(buffer.lineForRow(0)).toBe "{" + editor.insertText "}" + expect(buffer.lineForRow(0)).toBe "{}" + editor.setCursorBufferPosition([0, 1]) + editor.backspace() + expect(buffer.lineForRow(0)).toBe "}" + describe 'bracket-matcher:close-tag', -> beforeEach -> waitsForPromise ->