mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Make getNonWordCharacters take a position
This commit is contained in:
@@ -2052,14 +2052,13 @@ describe('TextEditor', () => {
|
||||
expect(scopeDescriptors[0].getScopesArray()).toEqual(['source.js'])
|
||||
expect(scopeDescriptors[1].getScopesArray()).toEqual(['source.js', 'string.quoted.single.js'])
|
||||
|
||||
editor.setScopedSettingsDelegate({
|
||||
getNonWordCharacters (scopes) {
|
||||
const result = '/\()"\':,.;<>~!@#$%^&*|+=[]{}`?'
|
||||
if (scopes.some(scope => scope.startsWith('string'))) {
|
||||
return result
|
||||
} else {
|
||||
return result + '-'
|
||||
}
|
||||
spyOn(editor.getBuffer().getLanguageMode(), 'getNonWordCharacters').andCallFake(function (position) {
|
||||
const result = '/\()"\':,.;<>~!@#$%^&*|+=[]{}`?'
|
||||
const scopes = this.scopeDescriptorForPosition(position).getScopesArray()
|
||||
if (scopes.some(scope => scope.startsWith('string'))) {
|
||||
return result
|
||||
} else {
|
||||
return result + '-'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -702,7 +702,7 @@ class Cursor extends Model {
|
||||
*/
|
||||
|
||||
getNonWordCharacters () {
|
||||
return this.editor.getNonWordCharacters(this.getScopeDescriptor().getScopesArray())
|
||||
return this.editor.getNonWordCharacters(this.getBufferPosition())
|
||||
}
|
||||
|
||||
changePosition (options, fn) {
|
||||
|
||||
@@ -4106,9 +4106,9 @@ class TextEditor {
|
||||
// for the purpose of word-based cursor movements.
|
||||
//
|
||||
// Returns a {String} containing the non-word characters.
|
||||
getNonWordCharacters (scopes) {
|
||||
getNonWordCharacters (position) {
|
||||
const languageMode = this.buffer.getLanguageMode()
|
||||
return (languageMode.getNonWordCharacters && languageMode.getNonWordCharacters(scopes)) ||
|
||||
return (languageMode.getNonWordCharacters && languageMode.getNonWordCharacters(position)) ||
|
||||
this.nonWordCharacters
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,8 @@ class TokenizedBuffer {
|
||||
return this.grammar.name
|
||||
}
|
||||
|
||||
getNonWordCharacters (scope) {
|
||||
getNonWordCharacters (position) {
|
||||
const scope = this.scopeDescriptorForPosition(position)
|
||||
return this.config.get('editor.nonWordCharacters', {scope})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user