Skip to content

Commit b8b1e46

Browse files
committed
Workaround clearing to first when using occurence
Conditionally skip workaround involving positioning of popups at proper position. Previously with `clearMultipleCursorsToFirstPosition` enabled, and using occurence, it would clear to second instead of first position.
1 parent 845d303 commit b8b1e46

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/occurrence-manager.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,10 @@ module.exports = class OccurrenceManager {
190190
// It is important to show autocomplete+ popup at proper position( popup shows up at last-selection ).
191191
// E.g. `c o f`(change occurrence in a-function) show autocomplete+ popup at closest occurrence.
192192
const closestRange = this.getClosestRangeForSelection(ranges, selection)
193-
ranges.splice(ranges.indexOf(closestRange), 1) // remove
194-
ranges.push(closestRange) // then push to last
193+
if (!this.vimState.getConfig('clearMultipleCursorsToFirstPosition')) {
194+
ranges.splice(ranges.indexOf(closestRange), 1) // remove
195+
ranges.push(closestRange) // then push to last
196+
}
195197

196198
rangesToSelect.push(...ranges)
197199

spec/occurrence-spec.coffee

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,3 +1201,19 @@ describe "Occurrence", ->
12011201
ensure null, mode: "normal", occurrenceText: []
12021202
atom.confirm.andCallFake ({buttons}) -> buttons.indexOf("Continue")
12031203
ensure "g o", mode: "normal", occurrenceText: ['oo', 'oo', 'oo', 'oo', 'oo']
1204+
1205+
describe "clearMultipleCursorsToFirstPosition setting", ->
1206+
beforeEach ->
1207+
settings.set('clearMultipleCursorsToFirstPosition', true)
1208+
1209+
it "clear multiple occurence cursors by respecting first cursor's position", ->
1210+
set
1211+
text: """
1212+
ooo: xxx: ooo:
1213+
xxx: ooo: xxx:
1214+
"""
1215+
cursor: [0, 0]
1216+
ensure "c o a e", mode: 'insert', numCursors: 3
1217+
editor.insertText('===')
1218+
ensure "escape"
1219+
ensure "escape", mode: 'normal', numCursors: 1, cursor: [0, 2]

0 commit comments

Comments
 (0)