mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Add has-selection class to editors with non-empty selections
This commit is contained in:
committed by
Antonio Scandurra
parent
f83ad6bb7c
commit
bfa410b114
@@ -466,6 +466,25 @@ describe('TextEditorComponent', () => {
|
||||
await component.getNextUpdatePromise()
|
||||
expect(element.dataset.encoding).toBe('ascii')
|
||||
})
|
||||
|
||||
it('adds the has-selection class when the editor has a non-empty selection', async () => {
|
||||
const {editor, element, component} = buildComponent()
|
||||
expect(element.classList.contains('has-selection')).toBe(false)
|
||||
|
||||
editor.setSelectedBufferRanges([
|
||||
[[0, 0], [0, 0]],
|
||||
[[1, 0], [1, 10]]
|
||||
])
|
||||
await component.getNextUpdatePromise()
|
||||
expect(element.classList.contains('has-selection')).toBe(true)
|
||||
|
||||
editor.setSelectedBufferRanges([
|
||||
[[0, 0], [0, 0]],
|
||||
[[1, 0], [1, 0]]
|
||||
])
|
||||
await component.getNextUpdatePromise()
|
||||
expect(element.classList.contains('has-selection')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('mini editors', () => {
|
||||
|
||||
@@ -365,6 +365,13 @@ class TextEditorComponent {
|
||||
className = className + ' mini'
|
||||
}
|
||||
|
||||
for (var i = 0; i < model.selections.length; i++) {
|
||||
if (!model.selections[i].isEmpty()) {
|
||||
className += ' has-selection'
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
const dataset = {encoding: model.getEncoding()}
|
||||
const grammar = model.getGrammar()
|
||||
if (grammar && grammar.scopeName) {
|
||||
|
||||
Reference in New Issue
Block a user