From 88eb803d91e2dfa94694009120121fac988ba804 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 6 Dec 2013 22:10:26 -0800 Subject: [PATCH 1/4] Mock season.writeFileSyne instead of fs.writeFileSync in config specs The spec suite has been overwriting my config directory in weird cases. While investigating it I noticed that we mock writeFileSync directly in these specs, but we actually use season to write the config cson. This makes this spec a bit simpler because it doesn't have to parse the CSON in the spec. Lower level assertions belong on the season package itself. --- spec/config-spec.coffee | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/config-spec.coffee b/spec/config-spec.coffee index fac7804f1..13785568f 100644 --- a/spec/config-spec.coffee +++ b/spec/config-spec.coffee @@ -108,10 +108,10 @@ describe "Config", -> expect(atom.config.getPositiveInt('editor.preferredLineLength', 80)).toBe 80 describe ".save()", -> - nodeFs = require 'fs' + CSON = require 'season' beforeEach -> - spyOn(nodeFs, 'writeFileSync') + spyOn(CSON, 'writeFileSync') jasmine.unspy atom.config, 'save' describe "when ~/.atom/config.json exists", -> @@ -122,12 +122,12 @@ describe "Config", -> atom.config.set("x.y.z", 3) atom.config.setDefaults("a.b", e: 4, f: 5) - nodeFs.writeFileSync.reset() + CSON.writeFileSync.reset() atom.config.save() - expect(nodeFs.writeFileSync.argsForCall[0][0]).toBe(path.join(atom.config.configDirPath, "atom.config.json")) - writtenConfig = JSON.parse(nodeFs.writeFileSync.argsForCall[0][1]) - expect(writtenConfig).toEqual atom.config.settings + expect(CSON.writeFileSync.argsForCall[0][0]).toBe(path.join(atom.config.configDirPath, "atom.config.json")) + writtenConfig = CSON.writeFileSync.argsForCall[0][1] + expect(writtenConfig).toBe atom.config.settings describe "when ~/.atom/config.json doesn't exist", -> it "writes any non-default properties to ~/.atom/config.cson", -> @@ -137,12 +137,12 @@ describe "Config", -> atom.config.set("x.y.z", 3) atom.config.setDefaults("a.b", e: 4, f: 5) - nodeFs.writeFileSync.reset() + CSON.writeFileSync.reset() atom.config.save() - expect(nodeFs.writeFileSync.argsForCall[0][0]).toBe(path.join(atom.config.configDirPath, "atom.config.cson")) + expect(CSON.writeFileSync.argsForCall[0][0]).toBe(path.join(atom.config.configDirPath, "atom.config.cson")) CoffeeScript = require 'coffee-script' - writtenConfig = CoffeeScript.eval(nodeFs.writeFileSync.argsForCall[0][1], bare: true) + writtenConfig = CSON.writeFileSync.argsForCall[0][1] expect(writtenConfig).toEqual atom.config.settings describe ".setDefaults(keyPath, defaults)", -> From 65fa5bf880e35076f34e3f30b4b1e4125744094c Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Sat, 7 Dec 2013 11:27:41 -0800 Subject: [PATCH 2/4] Upgrade to settings-view@0.50.0, closes #1264 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 08a0ac185..efb6be084 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,7 @@ "metrics": "0.12.0", "package-generator": "0.23.0", "release-notes": "0.15.0", - "settings-view": "0.49.0", + "settings-view": "0.50.0", "snippets": "0.17.0", "spell-check": "0.17.0", "status-bar": "0.24.0", From 796632c36c992cb61148779cb7ab022f5f40b822 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 6 Dec 2013 13:54:08 -0800 Subject: [PATCH 3/4] Refresh less cache before activating themes This ensures the import paths for themes contain the stylesheet directories Closes #1225 --- src/theme-manager.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/theme-manager.coffee b/src/theme-manager.coffee index becccf027..b34d07acf 100644 --- a/src/theme-manager.coffee +++ b/src/theme-manager.coffee @@ -53,10 +53,13 @@ class ThemeManager # the first/top theme to override later themes in the stack. themeNames = _.clone(themeNames).reverse() + @refreshLessCache() # Update cache for packages in core.themes config @packageManager.activatePackage(themeName) for themeName in themeNames - @refreshLessCache() + + @refreshLessCache() # Update cache again now that @getActiveThemes() is populated @loadUserStylesheet() @reloadBaseStylesheets() + @emit('reloaded') # Internal-only: From 34f71a2623d8f1954fcb18edcf8c0dd2e55946be Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 6 Dec 2013 09:18:16 -0800 Subject: [PATCH 4/4] Observe editor.tabLength config in TokenizedBuffer Closes #1224 --- spec/tokenized-buffer-spec.coffee | 10 ++++++++++ src/config.coffee | 4 ++-- src/tokenized-buffer.coffee | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/spec/tokenized-buffer-spec.coffee b/spec/tokenized-buffer-spec.coffee index 1fd9b98de..0ffd4181d 100644 --- a/spec/tokenized-buffer-spec.coffee +++ b/spec/tokenized-buffer-spec.coffee @@ -434,3 +434,13 @@ describe "TokenizedBuffer", -> describe "when the selector matches a run of multiple tokens at the position", -> it "returns the range covered by all contigous tokens (within a single line)", -> expect(tokenizedBuffer.bufferRangeForScopeAtPosition('.function', [1, 18])).toEqual [[1, 6], [1, 28]] + + describe "when the editor.tabLength config value changes", -> + it "updates the tab length of the tokenized lines", -> + buffer = atom.project.bufferForPathSync('sample.js') + buffer.setText('\ttest') + tokenizedBuffer = new TokenizedBuffer({buffer}) + fullyTokenize(tokenizedBuffer) + expect(tokenizedBuffer.tokenForPosition([0,0]).value).toBe ' ' + atom.config.set('editor.tabLength', 6) + expect(tokenizedBuffer.tokenForPosition([0,0]).value).toBe ' ' diff --git a/src/config.coffee b/src/config.coffee index 044bd3382..24990ab51 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -125,11 +125,11 @@ class Config # # keyPath - The {String} name of the key to retrieve # defaultValue - The integer {Number} to fall back to if the value isn't - # positive + # positive, defaults to 0. # # Returns the value from Atom's default settings, the user's configuration file, # or `defaultValue` if the key value isn't greater than zero. - getPositiveInt: (keyPath, defaultValue) -> + getPositiveInt: (keyPath, defaultValue=0) -> Math.max(@getInt(keyPath), 0) or defaultValue # Public: Sets the value for a configuration setting. diff --git a/src/tokenized-buffer.coffee b/src/tokenized-buffer.coffee index 0b6ba31dd..5a30c7de0 100644 --- a/src/tokenized-buffer.coffee +++ b/src/tokenized-buffer.coffee @@ -50,6 +50,9 @@ class TokenizedBuffer @subscribe @buffer, "changed", (e) => @handleBufferChange(e) @subscribe @buffer, "path-changed", => @state.set('bufferPath', @buffer.getPath()) + @subscribe atom.config.observe 'editor.tabLength', callNow: false, => + @setTabLength(atom.config.getPositiveInt('editor.tabLength')) + @reloadGrammar() serialize: -> @state.clone()