提交 c936b0f6 编写于 作者: B Benjamin Pasero

Jumpy cursor with trim trailing whitespace and autosave (fixes #18410)

上级 05ac1a76
......@@ -70,23 +70,21 @@ class TrimWhitespaceParticipant implements INamedSaveParticpant {
}
function findEditor(model: IModel, codeEditorService: ICodeEditorService): ICommonCodeEditor {
if (model.isAttachedToEditor()) {
const allEditors = codeEditorService.listCodeEditors();
for (let i = 0, len = allEditors.length; i < len; i++) {
const editor = allEditors[i];
const editorModel = editor.getModel();
let candidate: ICommonCodeEditor = null;
if (!editorModel) {
continue; // empty editor
}
if (model.isAttachedToEditor()) {
for (const editor of codeEditorService.listCodeEditors()) {
if (editor.getModel() === model) {
if (editor.isFocused()) {
return editor; // favour focussed editor if there are multiple
}
if (model === editorModel) {
return editor;
candidate = editor;
}
}
}
return null;
return candidate;
}
export class FinalNewLineParticipant implements INamedSaveParticpant {
......@@ -158,7 +156,7 @@ class FormatOnSaveParticipant implements INamedSaveParticpant {
}).then(edits => {
if (edits && versionNow === model.getVersionId()) {
const editor = this._findEditor(model);
const editor = findEditor(model, this._editorService);
if (editor) {
this._editsWithEditor(editor, edits);
} else {
......@@ -194,24 +192,6 @@ class FormatOnSaveParticipant implements INamedSaveParticpant {
forceMoveMarkers: true
};
}
private _findEditor(model: IModel) {
if (!model.isAttachedToEditor()) {
return;
}
let candidate: ICommonCodeEditor;
for (const editor of this._editorService.listCodeEditors()) {
if (editor.getModel() === model) {
if (editor.isFocused()) {
return editor;
} else {
candidate = editor;
}
}
}
return candidate;
}
}
class ExtHostSaveParticipant implements INamedSaveParticpant {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册