mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
keep scroll related key events in scrollable region
This commit is contained in:
parent
67de6c1d53
commit
c56c481890
|
@ -198,6 +198,16 @@ function onScrollHandler(e: globalThis.Event) {
|
|||
}
|
||||
}
|
||||
|
||||
function onKeypressHandler(e: KeyboardEvent) {
|
||||
if (e.ctrlKey || e.shiftKey) {
|
||||
return;
|
||||
}
|
||||
if (e.code === 'ArrowDown' || e.code === 'End' || e.code === 'ArrowUp' || e.code === 'Home') {
|
||||
// These should change the scroll position, not adjust the selected cell in the notebook
|
||||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
// if there is a scrollable output, it will be scrolled to the given value if provided or the bottom of the element
|
||||
function initializeScroll(scrollableElement: HTMLElement, disposables: DisposableStore, scrollTop?: number) {
|
||||
if (scrollableElement.classList.contains(scrollableClass)) {
|
||||
|
@ -205,6 +215,8 @@ function initializeScroll(scrollableElement: HTMLElement, disposables: Disposabl
|
|||
scrollableElement.scrollTop = scrollTop !== undefined ? scrollTop : scrollableElement.scrollHeight;
|
||||
scrollableElement.addEventListener('scroll', onScrollHandler);
|
||||
disposables.push({ dispose: () => scrollableElement.removeEventListener('scroll', onScrollHandler) });
|
||||
scrollableElement.addEventListener('keydown', onKeypressHandler);
|
||||
disposables.push({ dispose: () => scrollableElement.removeEventListener('keydown', onKeypressHandler) });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue