mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Add grammar scope to EditorView
Only works when the `grammar-changed` event has been triggered, and only implemented for Space Pen views.
This commit is contained in:
@@ -560,6 +560,7 @@ class EditorView extends View
|
||||
@trigger 'editor:path-changed'
|
||||
|
||||
@subscribe @editor, "grammar-changed", =>
|
||||
@addGrammarScopeClasses()
|
||||
@trigger 'editor:grammar-changed'
|
||||
|
||||
@subscribe @editor, 'selection-added', (selection) =>
|
||||
@@ -585,6 +586,11 @@ class EditorView extends View
|
||||
if @attached and @editor.buffer.isInConflict()
|
||||
_.defer => @showBufferConflictAlert(@editor) # Display after editor has a chance to display
|
||||
|
||||
addGrammarScopeClasses: ->
|
||||
scopeParts = @editor.getGrammar()?.scopeName?.split('.')
|
||||
classes = scopeParts.join(' ') if scopeParts?.length
|
||||
@addClass(classes) if classes?
|
||||
|
||||
getModel: ->
|
||||
@editor
|
||||
|
||||
|
||||
Reference in New Issue
Block a user