Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions x-pack/plugins/code/public/components/editor/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class EditorComponent extends React.Component<IProps> {
private container: HTMLElement | undefined;
private monaco: MonacoHelper | undefined;
private editor: editorInterfaces.IStandaloneCodeEditor | undefined;
private lineDecorations: string[] | null = null;

constructor(props: IProps, context: any) {
super(props, context);
Expand Down Expand Up @@ -104,11 +105,11 @@ export class EditorComponent extends React.Component<IProps> {
this.monaco.editor.updateOptions({ lineHeight: 38 });
} else if (!this.props.showBlame) {
this.destroyBlameWidgets();
this.monaco.editor.updateOptions({ lineHeight: 18 });
this.monaco.editor.updateOptions({ lineHeight: 18, lineDecorationsWidth: 16 });
}
if (prevProps.blames !== this.props.blames && this.props.showBlame) {
this.loadBlame(this.props.blames);
this.monaco.editor.updateOptions({ lineHeight: 38 });
this.monaco.editor.updateOptions({ lineHeight: 38, lineDecorationsWidth: 316 });
}
}
}
Expand All @@ -126,12 +127,7 @@ export class EditorComponent extends React.Component<IProps> {
macModifier={[Modifier.meta]}
winModifier={[Modifier.ctrl]}
/>
<div
tabIndex={0}
className="code-editor-container"
id="mainEditor"
style={{ paddingLeft: this.props.showBlame ? 300 : 0 }}
/>
<div tabIndex={0} className="code-editor-container" id="mainEditor" />
{this.renderReferences()}
</EuiFlexItem>
);
Expand All @@ -144,12 +140,27 @@ export class EditorComponent extends React.Component<IProps> {
this.blameWidgets = blames.map((b, index) => {
return new BlameWidget(b, index === 0, this.monaco!.editor!);
});
if (!this.lineDecorations) {
this.lineDecorations = this.monaco!.editor!.deltaDecorations(
[],
[
{
range: new monaco.Range(1, 1, Infinity, 1),
options: { isWholeLine: true, linesDecorationsClassName: 'code-line-decoration' },
},
]
);
}
}

public destroyBlameWidgets() {
if (this.blameWidgets) {
this.blameWidgets.forEach((bw: BlameWidget) => bw.destroy());
}
if (this.lineDecorations) {
this.monaco!.editor!.deltaDecorations(this.lineDecorations!, []);
this.lineDecorations = null;
}
this.blameWidgets = null;
}

Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/code/public/components/main/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,8 @@
text-align: center;
flex-shrink: 0;
}

.code-line-decoration {
border-right: $euiBorderThick;
width: 316px !important;
}
4 changes: 2 additions & 2 deletions x-pack/plugins/code/public/monaco/blame/blame_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export class BlameWidget implements Editor.IContentWidget {
private update() {
const { fontSize, lineHeight } = this.editor.getConfiguration().fontInfo;
this.domNode.style.position = 'relative';
this.domNode.style.left = '-362px';
this.domNode.style.width = '300px';
this.domNode.style.left = '-332px';
this.domNode.style.width = '316px';
this.domNode.style.fontSize = `${fontSize}px`;
this.domNode.style.lineHeight = `${lineHeight}px`;
const element = React.createElement(
Expand Down