mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-09 13:15:37 +03:00
Merge pull request #16814 from atom/mb-default-scope-descriptor
Provide a default scope descriptor if language mode doesn't provide them
This commit is contained in:
commit
983406e166
@ -6747,6 +6747,14 @@ describe('TextEditor', () => {
|
||||
editor.destroy()
|
||||
})
|
||||
|
||||
describe('.scopeDescriptorForBufferPosition(position)', () => {
|
||||
it('returns a default scope descriptor when no language mode is assigned', () => {
|
||||
editor = new TextEditor({buffer: new TextBuffer()})
|
||||
const scopeDescriptor = editor.scopeDescriptorForBufferPosition([0, 0])
|
||||
expect(scopeDescriptor.getScopesArray()).toEqual(['text'])
|
||||
})
|
||||
})
|
||||
|
||||
describe('.shouldPromptToSave()', () => {
|
||||
beforeEach(async () => {
|
||||
editor = await atom.workspace.open('sample.js')
|
||||
|
@ -11,6 +11,7 @@ const Cursor = require('./cursor')
|
||||
const Selection = require('./selection')
|
||||
const NullGrammar = require('./null-grammar')
|
||||
const TextMateLanguageMode = require('./text-mate-language-mode')
|
||||
const ScopeDescriptor = require('./scope-descriptor')
|
||||
|
||||
const TextMateScopeSelector = require('first-mate').ScopeSelector
|
||||
const GutterContainer = require('./gutter-container')
|
||||
@ -3655,7 +3656,10 @@ class TextEditor {
|
||||
//
|
||||
// Returns a {ScopeDescriptor}.
|
||||
scopeDescriptorForBufferPosition (bufferPosition) {
|
||||
return this.buffer.getLanguageMode().scopeDescriptorForPosition(bufferPosition)
|
||||
const languageMode = this.buffer.getLanguageMode()
|
||||
return languageMode.scopeDescriptorForPosition
|
||||
? languageMode.scopeDescriptorForPosition(bufferPosition)
|
||||
: new ScopeDescriptor({scopes: ['text']})
|
||||
}
|
||||
|
||||
// Extended: Get the range in buffer coordinates of all tokens surrounding the
|
||||
|
Loading…
Reference in New Issue
Block a user