Change:
Testing have a couple of lines in sticky scroll Focus sticky scroll scroll inside the file to a place that sticky scroll lines disappear scroll to a place that has sticky scroll lines again Observe: focus is lost. I would have expected that focus is kept.
Closing the issue since this is actually by design. Still I would have expected otherwise.
I am actually reopening it since I think the behavior is not good when scrolling using the scroll bar / minimap
Do the following: focus sticky scroll use the minimap to scroll to the top of the file whithout releasing the mouse Observe: sticky scroll disappears and focus is gone Scroll into the file again Observe: sticky scroll apprears without focus. I would have expected in this case that the focus is preserved since I never released the mouse button.
For the person who will be doing the verification, a regression has been found relating to the incorrect focusing of the sticky scroll which has already been fixed in the following PR: You may track its release through the corresponding issue: Please test once the other PR is released on insiders. In the meantime the label unreleased will be . Alternatively test on Code OSS.

Discussion:
this._stickyScrollVisibleContextKey = EditorContextKeys.stickyScrollVisible.bindTo(this._contextKeyService); const focusTracker = this._register(dom.trackFocus(this._stickyScrollWidget.getDomNode())); this._register(focusTracker.onDidBlur(_ => { <del> this._disposeFocusStickyScrollStore(); </del> <ins> const height = this._stickyScrollWidget.getDomNode().clientHeight; if (height !== 0) { this._disposeFocusStickyScrollStore(); } else { // If the height is 0, then the blur has been caused by scrolling. In that case keep the focus on the sticky scroll. this._focusedStickyElementIndex = -1; this.focus(); } </ins> })); this._register(focusTracker.onDidFocus(_ => { this.focus();

this._stickyScrollWidget.setState(this._widgetState); } else { this._stickyElements = this._stickyScrollWidget.getDomNode().children; <del> if (this._stickyElements.length === 0) { this._disposeFocusStickyScrollStore(); </del> <ins> // Suppose that previously the sticky scroll widget had height 0, then if there are visible lines, set the last line as focused if (this._focusedStickyElementIndex === -1) { </ins> this._stickyScrollWidget.setState(this._widgetState); <ins> this._focusedStickyElementIndex = this._stickyElements.length - 1; if (this._focusedStickyElementIndex !== -1) { (this._stickyElements.item(this._focusedStickyElementIndex) as HTMLDivElement).focus(); } </ins> } else { const focusedStickyElementLineNumber = this._stickyScrollWidget.lineNumbers[this._focusedStickyElementIndex]; this._stickyScrollWidget.setState(this._widgetState); <del> const previousFocusedLineNumberExists = this._stickyScrollWidget.lineNumbers.includes(focusedStickyElementLineNumber); </del> <ins> // Suppose that after setting the state, there are no sticky lines, set the focused index to -1 if (this._stickyElements.length === 0) { this._focusedStickyElementIndex = -1; } else { const previousFocusedLineNumberExists = this._stickyScrollWidget.lineNumbers.includes(focusedStickyElementLineNumber); </ins> <del> // If the line number is still there, do not change anything // If the line number is not there, set the new focused line to be the last line if (!previousFocusedLineNumberExists) { this._focusedStickyElementIndex = this._stickyElements.length - 1; </del> <ins> // If the line number is still there, do not change anything // If the line number is not there, set the new focused line to be the last line if (!previousFocusedLineNumberExists) { this._focusedStickyElementIndex = this._stickyElements.length - 1; } (this._stickyElements.item(this._focusedStickyElementIndex) as HTMLDivElement).focus(); </ins> } <del> (this._stickyElements.item(this._focusedStickyElementIndex) as HTMLDivElement).focus(); </del> } } }

dom.clearNode(this._rootDomNode); this._disposableStore.clear(); this._lineNumbers.length = 0; <del> this._lastLineRelativePosition = state.lastLineRelativePosition; this._lineNumbers = state.lineNumbers; </del> <ins> const editorLineHeight = this._editor.getOption(EditorOption.lineHeight); const futureWidgetHeight = state.lineNumbers.length * editorLineHeight + state.lastLineRelativePosition; if (futureWidgetHeight > 0) { this._lastLineRelativePosition = state.lastLineRelativePosition; this._lineNumbers = state.lineNumbers; } else { this._lastLineRelativePosition = 0; this._lineNumbers = []; } </ins> this._renderRootNode(); }