Skip to content

Commit 396e089

Browse files
revert: don't restore selections (#413)
1 parent 0d3042d commit 396e089

2 files changed

Lines changed: 17 additions & 30 deletions

File tree

src/DocumentWatcher.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as path from 'path'
22
import {
33
Disposable,
4-
Selection,
54
TextDocument,
65
TextDocumentSaveReason,
76
TextEditor,
@@ -39,8 +38,6 @@ export default class DocumentWatcher {
3938

4039
const subscriptions: Disposable[] = []
4140

42-
let previousSelections: Selection[] = []
43-
4441
this.handleTextEditorChange(window.activeTextEditor)
4542

4643
subscriptions.push(
@@ -65,11 +62,6 @@ export default class DocumentWatcher {
6562

6663
subscriptions.push(
6764
workspace.onDidSaveTextDocument(doc => {
68-
const activeEditor = window.activeTextEditor
69-
if (activeEditor && previousSelections.length) {
70-
activeEditor.selections = previousSelections
71-
}
72-
7365
if (path.basename(doc.fileName) === '.editorconfig') {
7466
this.log('.editorconfig file saved.')
7567
}
@@ -78,11 +70,6 @@ export default class DocumentWatcher {
7870

7971
subscriptions.push(
8072
workspace.onWillSaveTextDocument(async e => {
81-
const activeEditor = window.activeTextEditor
82-
const activeDoc = activeEditor?.document
83-
if (activeDoc && activeDoc === e.document && activeEditor) {
84-
previousSelections = [...activeEditor.selections]
85-
}
8673
const transformations = this.calculatePreSaveTransformations(
8774
e.document,
8875
e.reason,

src/test/suite/index.test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -285,24 +285,24 @@ suite('EditorConfig extension', function () {
285285
)
286286
})
287287

288-
test('keep selection on format', async () => {
289-
await withSetting('insert_final_newline', 'true', {
290-
fileName: 'test-selection',
291-
}).saveText('foobar')
292-
assert(window.activeTextEditor, 'no active editor')
288+
// test('keep selection on format', async () => {
289+
// await withSetting('insert_final_newline', 'true', {
290+
// fileName: 'test-selection',
291+
// }).saveText('foobar')
292+
// assert(window.activeTextEditor, 'no active editor')
293293

294-
// Before saving, the selection is on line 0. This should remain unchanged.
295-
assert.strictEqual(
296-
window.activeTextEditor.selection.start.line,
297-
0,
298-
'editor selection start line changed',
299-
)
300-
assert.strictEqual(
301-
window.activeTextEditor.selection.end.line,
302-
0,
303-
'editor selection end line changed',
304-
)
305-
})
294+
// // Before saving, the selection is on line 0. This should remain unchanged.
295+
// assert.strictEqual(
296+
// window.activeTextEditor.selection.start.line,
297+
// 0,
298+
// 'editor selection start line changed',
299+
// )
300+
// assert.strictEqual(
301+
// window.activeTextEditor.selection.end.line,
302+
// 0,
303+
// 'editor selection end line changed',
304+
// )
305+
// })
306306
})
307307

308308
function withSetting(

0 commit comments

Comments
 (0)