Change:
Re , I was editing the endgame notebook in VS Code repo but it keeps moving the cursor to the next line, which breaks typing. It's very likely an issue with these two settings combined "files.autoSave": "afterDelay" We seems to have the same issue for files in text editor but untitled file doesn't suffer from this as it can't be auto saved. I wonder if we should have some special treatment for notebook cells, as it's very usual to create new cells, which are always empty at the beginning, typing in the first line is making it almost impossible. Maybe we could keep the cursor position for this scenario.

Discussion:
@ITextModelService private readonly textModelService: ITextModelService, @IBulkEditService private readonly bulkEditService: IBulkEditService, @IConfigurationService private readonly configurationService: IConfigurationService, <del> ) { } </del> <ins> ) { } </ins> async participate(workingCopy: IStoredFileWorkingCopy<IStoredFileWorkingCopyModel>, context: { reason: SaveReason }, progress: IProgress<IProgressStep>, token: CancellationToken): Promise<void> { if (!workingCopy.model || !(workingCopy.model instanceof NotebookFileWorkingCopyModel)) {

async participate(workingCopy: IStoredFileWorkingCopy<IStoredFileWorkingCopyModel>, context: { reason: SaveReason }, progress: IProgress<IProgressStep>, _token: CancellationToken): Promise<void> { if (this.configurationService.getValue<boolean>('files.trimFinalNewlines')) { <del> this.doTrimFinalNewLines(workingCopy, context.reason === SaveReason.AUTO, progress); </del> <ins> await this.doTrimFinalNewLines(workingCopy, context.reason === SaveReason.AUTO, progress); </ins> } }

constructor( @IConfigurationService private readonly configurationService: IConfigurationService, @IBulkEditService private readonly bulkEditService: IBulkEditService, <ins> @IEditorService private readonly editorService: IEditorService, </ins> ) { } async participate(workingCopy: IStoredFileWorkingCopy<IStoredFileWorkingCopyModel>, context: { reason: SaveReason }, progress: IProgress<IProgressStep>, _token: CancellationToken): Promise<void> { if (this.configurationService.getValue('files.insertFinalNewline')) { <del> this.doInsertFinalNewLine(workingCopy, context, progress); </del> <ins> await this.doInsertFinalNewLine(workingCopy, context.reason === SaveReason.AUTO, progress); </ins> } } <del> private async doInsertFinalNewLine(workingCopy: IStoredFileWorkingCopy<IStoredFileWorkingCopyModel>, context: { reason: SaveReason }, progress: IProgress<IProgressStep>): Promise<void> { </del> <ins> private async doInsertFinalNewLine(workingCopy: IStoredFileWorkingCopy<IStoredFileWorkingCopyModel>, isAutoSaved: boolean, progress: IProgress<IProgressStep>): Promise<void> { </ins> if (!workingCopy.model || !(workingCopy.model instanceof NotebookFileWorkingCopyModel)) { return; }

const disposable = new DisposableStore(); const notebook = workingCopy.model.notebookModel; <ins> // get initial cursor positions const activeCellEditor = getActiveCellCodeEditor(this.editorService); let selections; if (activeCellEditor) { selections = activeCellEditor.getSelections() ?? []; } </ins> try { const allCellEdits = await Promise.all(notebook.cells.map(async (cell) => { if (cell.cellKind !== CellKind.Code) {

const filteredEdits = allCellEdits.filter(edit => edit !== undefined) as ResourceEdit[]; await this.bulkEditService.apply(filteredEdits, { label: localize('insertFinalNewLine', "Insert Final New Line"), code: 'undoredo.insertFinalNewLine' }); <ins> // set cursor back to initial position after inserting final new line if (activeCellEditor && selections) { activeCellEditor.setSelections(selections); } </ins> } finally { progress.report({ increment: 100 }); disposable.dispose();