diff --git a/news/2 Fixes/10952.md b/news/2 Fixes/10952.md new file mode 100644 index 000000000000..ad13a0db7e7b --- /dev/null +++ b/news/2 Fixes/10952.md @@ -0,0 +1 @@ +Scrolling in cells doesn't happen on new line. \ No newline at end of file diff --git a/src/datascience-ui/react-common/monacoEditor.tsx b/src/datascience-ui/react-common/monacoEditor.tsx index 7d00912ab025..2f4c119103ea 100644 --- a/src/datascience-ui/react-common/monacoEditor.tsx +++ b/src/datascience-ui/react-common/monacoEditor.tsx @@ -188,8 +188,11 @@ export class MonacoEditor extends React.Component { this.windowResized(); - // Also recompute our visible line heights + // Recompute visible line tops this.debouncedComputeLineTops(); + + // A layout change may be because of a new line + this.throttledScrollCurrentPosition(editor); }) ); @@ -243,7 +246,9 @@ export class MonacoEditor extends React.Component { this.throttledUpdateWidgetPosition(); - this.throttledScrollCurrentPosition(editor); + + // Do this after the cursor changes so the text has time to appear + setTimeout(() => this.throttledScrollCurrentPosition(editor), 0); }) ); @@ -643,14 +648,12 @@ export class MonacoEditor extends React.Component