This repository was archived by the owner on Mar 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17.3k
Restore color rendering following Electron 2.0 update #17380
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d65a097
Fix #17356
jasonrudolph 8bded0b
Merge master into fix-color-problems-using-electron-2.0
jasonrudolph 82ba358
Read user's custom Electron switches from config file
jasonrudolph c71de84
Look for .electron-switches in ATOM_HOME
jasonrudolph 6985fb0
Use Atom's standard config file to set custom color profile
jasonrudolph b67f8ac
:shirt:
jasonrudolph 266e011
☠☕ Decaffienate ScopeDescriptor
jasonrudolph f9ba602
Gracefully handle missing config file
jasonrudolph c3d38ed
Support configuring color profile via settings UI
jasonrudolph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Extended: Wraps an {Array} of `String`s. The Array describes a path from the | ||
// root of the syntax tree to a token including _all_ scope names for the entire | ||
// path. | ||
// | ||
// Methods that take a `ScopeDescriptor` will also accept an {Array} of {String} | ||
// scope names e.g. `['.source.js']`. | ||
// | ||
// You can use `ScopeDescriptor`s to get language-specific config settings via | ||
// {Config::get}. | ||
// | ||
// You should not need to create a `ScopeDescriptor` directly. | ||
// | ||
// * {TextEditor::getRootScopeDescriptor} to get the language's descriptor. | ||
// * {TextEditor::scopeDescriptorForBufferPosition} to get the descriptor at a | ||
// specific position in the buffer. | ||
// * {Cursor::getScopeDescriptor} to get a cursor's descriptor based on position. | ||
// | ||
// See the [scopes and scope descriptor guide](http://flight-manual.atom.io/behind-atom/sections/scoped-settings-scopes-and-scope-descriptors/) | ||
// for more information. | ||
module.exports = | ||
class ScopeDescriptor { | ||
static fromObject (scopes) { | ||
if (scopes instanceof ScopeDescriptor) { | ||
return scopes | ||
AFF9 | } else { | |
return new ScopeDescriptor({scopes}) | ||
} | ||
} | ||
|
||
/* | ||
Section: Construction and Destruction | ||
*/ | ||
|
||
// Public: Create a {ScopeDescriptor} object. | ||
// | ||
// * `object` {Object} | ||
// * `scopes` {Array} of {String}s | ||
constructor ({scopes}) { | ||
this.scopes = scopes | ||
} | ||
|
||
// Public: Returns an {Array} of {String}s | ||
getScopesArray () { | ||
return this.scopes | ||
} | ||
|
||
getScopeChain () { | ||
// For backward compatibility, prefix TextMate-style scope names with | ||
// leading dots (e.g. 'source.js' -> '.source.js'). | ||
if (this.scopes[0] != null && this.scopes[0].includes('.')) { | ||
let result = '' | ||
for (let i = 0; i < this.scopes.length; i++) { | ||
const scope = this.scopes[i] | ||
if (i > 0) { result += ' ' } | ||
if (scope[0] !== '.') { result += '.' } | ||
result += scope | ||
} | ||
return result | ||
} else { | ||
return this.scopes.join(' ') | ||
} | ||
} | ||
|
||
toString () { | ||
return this.getScopeChain() | ||
} | ||
|
||
isEqual (other) { | ||
if (this.scopes.length !== other.scopes.length) { | ||
return false | ||
} | ||
for (let i = 0; i < this.scopes.length; i++) { | ||
const scope = this.scopes[i] | ||
if (scope !== other.scopes[i]) { | ||
return false | ||
} | ||
} | ||
return true | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if we could reuse this
Config
and/orConfigFile
instance inAtomApplication
, in order to avoid reading the config file twice on startup (and also to avoid duplicating the code for locating the config file). That said, I don't think it is necessarily important enough to block merging this PR.