mirror of
https://github.com/atom/atom.git
synced 2026-01-24 22:38:20 -05:00
Merge pull request #16518 from atom/ns-as-fix-add-selection
Don't add fully-contained selections above/below
This commit is contained in:
@@ -2376,6 +2376,19 @@ describe('TextEditor', () => {
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
it('does not create a new selection if it would be fully contained within another selection', () => {
|
||||
editor.setText('abc\ndef\nghi\njkl\nmno')
|
||||
editor.setCursorBufferPosition([0, 1])
|
||||
|
||||
let addedSelectionCount = 0
|
||||
editor.onDidAddSelection(() => { addedSelectionCount++ })
|
||||
|
||||
editor.addSelectionBelow()
|
||||
editor.addSelectionBelow()
|
||||
editor.addSelectionBelow()
|
||||
expect(addedSelectionCount).toBe(3)
|
||||
})
|
||||
})
|
||||
|
||||
describe('.addSelectionAbove()', () => {
|
||||
@@ -2498,6 +2511,19 @@ describe('TextEditor', () => {
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
it('does not create a new selection if it would be fully contained within another selection', () => {
|
||||
editor.setText('abc\ndef\nghi\njkl\nmno')
|
||||
editor.setCursorBufferPosition([4, 1])
|
||||
|
||||
let addedSelectionCount = 0
|
||||
editor.onDidAddSelection(() => { addedSelectionCount++ })
|
||||
|
||||
editor.addSelectionAbove()
|
||||
editor.addSelectionAbove()
|
||||
editor.addSelectionAbove()
|
||||
expect(addedSelectionCount).toBe(3)
|
||||
})
|
||||
})
|
||||
|
||||
describe('.splitSelectionsIntoLines()', () => {
|
||||
|
||||
@@ -832,8 +832,12 @@ class Selection {
|
||||
if (clippedRange.isEmpty()) continue
|
||||
}
|
||||
|
||||
const selection = this.editor.addSelectionForScreenRange(clippedRange)
|
||||
selection.setGoalScreenRange(range)
|
||||
const containingSelections = this.editor.selectionsMarkerLayer.findMarkers({containsScreenRange: clippedRange})
|
||||
if (containingSelections.length === 0) {
|
||||
const selection = this.editor.addSelectionForScreenRange(clippedRange)
|
||||
selection.setGoalScreenRange(range)
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -854,8 +858,12 @@ class Selection {
|
||||
if (clippedRange.isEmpty()) continue
|
||||
}
|
||||
|
||||
const selection = this.editor.addSelectionForScreenRange(clippedRange)
|
||||
selection.setGoalScreenRange(range)
|
||||
const containingSelections = this.editor.selectionsMarkerLayer.findMarkers({containsScreenRange: clippedRange})
|
||||
if (containingSelections.length === 0) {
|
||||
const selection = this.editor.addSelectionForScreenRange(clippedRange)
|
||||
selection.setGoalScreenRange(range)
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user