mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-11 11:15:24 +03:00
Make method to assign specific grammar
This commit is contained in:
parent
8d4b9c2485
commit
e9e52f5052
@ -43,7 +43,7 @@ class GrammarListView {
|
||||
if (grammar === this.autoDetect) {
|
||||
atom.textEditors.clearGrammarOverride(this.editor)
|
||||
} else {
|
||||
atom.textEditors.setGrammarOverride(this.editor, grammar.scopeName)
|
||||
atom.grammars.assignGrammar(this.editor, grammar)
|
||||
}
|
||||
},
|
||||
didCancelSelection: () => {
|
||||
|
@ -142,6 +142,22 @@ class GrammarRegistry {
|
||||
return true
|
||||
}
|
||||
|
||||
// Extended: Force a {TextBuffer} to use a different grammar than the
|
||||
// one that would otherwise be selected for it.
|
||||
//
|
||||
// * `buffer` The {TextBuffer} whose grammar will be set.
|
||||
// * `grammar` The {Grammar} of the desired languageMode.
|
||||
//
|
||||
// Returns a {Boolean} that indicates whether the assignment was sucessful
|
||||
assignGrammar (buffer, grammar) {
|
||||
if (buffer.getBuffer) buffer = buffer.getBuffer()
|
||||
if (!grammar) return false
|
||||
this.languageOverridesByBufferId.set(buffer.id, grammar.scopeName || null)
|
||||
this.grammarScoresByBuffer.set(buffer, null)
|
||||
buffer.setLanguageMode(this.languageModeForGrammarAndBuffer(grammar, buffer))
|
||||
return true
|
||||
}
|
||||
|
||||
// Extended: Get the `languageId` that has been explicitly assigned to
|
||||
// to the given buffer, if any.
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user