Skip to content

Commit

Permalink
Remove logic for loading a user's editor settings
Browse files Browse the repository at this point in the history
Atom v1.25.0 changed how user configs were updated on disk, subsequently
removing some properties which we were relying on to find `config.cson`.
This is causing `loadEditorSettings` to raise an exception at startup.

Since this feature was headed for the incinerator anyway, we may as well
cull it early (it was a stupid idea to begin with, among many others yet
to be obliterated).

See #3.
  • Loading branch information
Alhadis committed Mar 21, 2018
1 parent 681da42 commit ada9f85
Showing 1 changed file with 1 addition and 50 deletions.
51 changes: 1 addition & 50 deletions lib/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ class Reporter{
* @return {Promise}
*/
static beforeStart(main){
const promises = [this.loadEditorSettings()];
const promises = [];

// Load JavaScript grammar to provide syntax highlighting
if(main.options.formatCode){
Expand All @@ -681,55 +681,6 @@ class Reporter{

return Promise.all(promises);
}



/**
* Attempt to load user's config to improve feedback quality.
*
* User configs are parsed statically. Because this feature is so cosmetic,
* it's not worth adding CSON/CoffeeScript as a hard dependency over.
*
* @return {Promise}
*/
static loadEditorSettings(){

return new Promise((resolve, reject) => {
const configPath = atom.config.configFilePath;

fs.readFile(configPath, (error, data) => {
if(error) return reject(error);

// Break the config's content apart by top-level scope
const scopes = {};
data.toString().split(/^(?=\S)/gm).forEach(s => {
const scope = /^(?:"(?:[^"\\]|\\.)+"|'(?:[^'\\]|\\.)+'|\w+)/;
const editor = /\n {2}editor:\n[^\x00]+?\n(?: {2}\S|$)/;
const ed = (s.match(editor) || [""])[0];

// Pinch a bunch of parsed editor settings
if(s = (s.match(scope) || [""])[0].replace(/["']/g, ""))
scopes[s] = {
fontFamily: (ed.match(/^ +fontFamily:\s*("|')(.+)\1/im) || []).pop(),
fontSize: (ed.match(/^ +fontSize:\s*([\d.]+)/im) || []).pop(),
lineHeight: (ed.match(/^ +lineHeight:\s*([\d.]+)/im) || []).pop(),
tabLength: (ed.match(/^ +tabLength:\s*(\d+)/im) || []).pop()
};
});

// Now collate them in ascending order of precedence
const ed = {};
for(let scope of ["*", ".atom-mocha"]){
for(let k in scopes[scope]){
let v = scopes[scope][k]
if(v != null) ed[k] = v
}
}
Reporter.editorSettings = ed;
resolve();
});
});
}
}


Expand Down

0 comments on commit ada9f85

Please sign in to comment.