Skip to content

Commit 967f7b1

Browse files
author
David Kutugata
authored
The native editor will now wrap all its content (microsoft#7336)
* The native editor will now wrap all its content instead of showing a horizontal scrollbar. * dynamically change change the width of the cell results div to make the scrollbar appear. * Moved the styles to nativeEditor.less and force update of the native editor when window is resized.
1 parent 044e267 commit 967f7b1

4 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎news/2 Fixes/7272.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The native editor will now wrap all its content instead of showing a horizontal scrollbar.

‎src/datascience-ui/interactive-common/cell.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,9 @@ export class Cell extends React.Component<ICellProps, ICellState> {
448448
// React-markdown expects that the source is a string
449449
const source = concatMultilineString(markdown.source);
450450
const Transform = transforms['text/markdown'];
451+
const MarkdownClassName = 'markdown-cell-output';
451452

452-
return [<Transform key={0} data={source} />];
453+
return [<div className={MarkdownClassName}><Transform key={0} data={source} /></div>];
453454
}
454455

455456
// tslint:disable-next-line: max-func-body-length

‎src/datascience-ui/native-editor/nativeEditor.less‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,19 @@
4646
justify-self: right;
4747
}
4848

49+
// make the width of the div be a bit less than the width of the window,
50+
// the 95 pixels removed account for the space the padding and controls
51+
// on the left take in the native Editor.
4952
.cell-output {
5053
margin-top: 5px;
5154
background: transparent;
55+
width: calc(95vw - 95px);
56+
overflow-x: scroll;
57+
}
58+
59+
.markdown-cell-output {
60+
width: calc(95vw - 95px);
61+
overflow-x: scroll;
5262
}
5363

5464
.cell-outer-editable {
@@ -195,3 +205,6 @@
195205
margin-right: 0px;
196206
}
197207

208+
#content-panel-div {
209+
overflow: hidden;
210+
}

‎src/datascience-ui/native-editor/nativeEditor.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ export class NativeEditor extends React.Component<INativeEditorProps, IMainState
6565

6666
public componentDidMount() {
6767
window.addEventListener('keydown', this.mainKeyDown);
68+
window.addEventListener('resize', () => this.forceUpdate(), true);
6869
}
6970

7071
public componentWillUnmount() {
7172
window.removeEventListener('keydown', this.mainKeyDown);
73+
window.removeEventListener('resize', () => this.forceUpdate());
7274
// Dispose of our state controller so it stops listening
7375
this.stateController.dispose();
7476
}

0 commit comments

Comments
 (0)