Change:
<!-- Do Not Delete This! bugreporttemplate --<!-- Please read our Rules of Conduct: --<!-- Read our guide about submitting issues: --<!-- Search existing issues to avoid creating duplicates. --<!-- Test using the latest Insiders build to see if your issue has already been fixed: --<!-- Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. --<!-- Launch with to check. --Does this issue occur when all extensions are disabled?: Yes/No <!-- If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. --<!-- Issues caused by an extension need to be reported directly to the extension publisher. The 'Help Report Issue' dialog can assist with this. --- VS Code Version: OS Version: Steps to Reproduce: a new notebook a code cell a markdown cell with a few lines such as follows Go into preview mode in markdown Edit first cell to get into notebook mode Arrow down to select markdown cell and hit enter Watch how the mardown cell scrolls up in the notebook view Go back to preview mode Scroll the notebook to view the first cell again and edit it Now select the markdown cell using the mouse Double click the mardown cell to edit it and wathc how it does not scroll!! I.e. using keyboard vs mouse results in different behaviour with scrolliing of the notebook. Ideally I would expect there to be no automatic scrolling when editing using keyboard, just as with mouse given the md cell is already in view we should not scroll this cell !
When pressing enter, we try to reveal the cursor selection in the cell editor into view by calling which uses the reveal type My expectation is it only scrolls the cell if it's out of the viewport but currently it always reveals the cell to the top of the viewport. Changing the reveal type to does fix the problem (as it should behave, here I'm not necessarily suggesting we change the reveal type in ).
Assigning to Feb milestone as the experience is quite bad. What surprised me is we didn't get user reports for this, which made me wonder how many users edit markdown cells after they are initially created.

Discussion:
const element = this.view.element(viewIndex); if (element.editorAttached) { <del> this._revealRangeCommon(viewIndex, range, false, false); </del> <ins> this._revealRangeCommon(viewIndex, range); </ins> } else { const elementHeight = this.view.elementHeight(viewIndex); <del> let upwards = false; </del> <ins> let alignHint: 'top' | 'bottom' | undefined = undefined; </ins> if (elementTop + elementHeight <= scrollTop) { <del> // scroll downwards </del> <ins> // scroll up </ins> this.view.setScrollTop(elementTop); <del> upwards = false; </del> <ins> alignHint = 'top'; </ins> } else if (elementTop >= wrapperBottom) { <del> // scroll upwards </del> <ins> // scroll down </ins> this.view.setScrollTop(elementTop - this.view.renderHeight / 2); <del> upwards = true; </del> <ins> alignHint = 'bottom'; </ins> } const editorAttachedPromise = new Promise<void>((resolve, reject) => {

}); return editorAttachedPromise.then(() => { <del> this._revealRangeCommon(viewIndex, range, true, upwards); </del> <ins> this._revealRangeCommon(viewIndex, range, alignHint); </ins> }); } }

} } <del> private _revealRangeCommon(viewIndex: number, range: Selection | Range, newlyCreated: boolean, alignToBottom: boolean) { </del> <ins> private _revealRangeCommon(viewIndex: number, range: Selection | Range, alignHint?: 'top' | 'bottom' | undefined) { </ins> const element = this.view.element(viewIndex); const scrollTop = this.getViewScrollTop(); const wrapperBottom = this.getViewScrollBottom();

this.view.setScrollTop(positionTop - 30); } else if (positionTop > wrapperBottom) { this.view.setScrollTop(scrollTop + positionTop - wrapperBottom + 30); <del> } else if (newlyCreated) { // newly scrolled into view if (alignToBottom) { // align to the bottom this.view.setScrollTop(scrollTop + positionTop - wrapperBottom + 30); } else { // align to to top this.view.setScrollTop(positionTop - 30); } </del> <ins> } else if (alignHint === 'bottom') { // Scrolled into view from below this.view.setScrollTop(scrollTop + positionTop - wrapperBottom + 30); } else if (alignHint === 'top') { // Scrolled into view from above this.view.setScrollTop(positionTop - 30); </ins> } element.revealRangeInCenter(range); } //#endregion