Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit d22ed70

Browse files
committed
grammar
1 parent c56f672 commit d22ed70

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

lib/atom/atom-text-editor.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ export default class AtomTextEditor extends React.Component {
8080

8181
componentDidMount() {
8282
const modelProps = extractProps(this.props, editorCreationProps);
83+
if (!modelProps.grammar && modelProps.buffer) {
84+
modelProps.grammar = atom.grammars.selectGrammarWithScore(
85+
modelProps.buffer.getPath(),
86+
modelProps.buffer.getText());
87+
}
88+
8389

8490
this.refParent.map(element => {
8591
const editor = new TextEditor(modelProps);

lib/views/commit-view.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ export default class CommitView extends React.Component {
193193
buffer={this.props.messageBuffer}
194194
workspace={this.props.workspace}
195195
didChangeCursorPosition={this.didMoveCursor}
196+
grammar={atom.grammars.selectGrammarWithScore(
197+
this.props.messageBuffer.getPath(),
198+
this.props.messageBuffer.getText(),
199+
)}
196200
/>
197201
<button
198202
ref={this.refCoAuthorToggle.setter}

lib/views/patch-preview-view.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,19 @@ export default class PatchPreviewView extends React.Component {
6161
}
6262

6363
render() {
64+
const buffer = this.state.previewPatchBuffer.getBuffer();
6465
return (
6566
<AtomTextEditor
66-
buffer={this.state.previewPatchBuffer.getBuffer()}
67+
buffer={buffer}
6768
readOnly={true}
6869
lineNumberGutterVisible={false}
6970
autoHeight={true}
7071
autoWidth={false}
71-
softWrapped={false}>
72+
softWrapped={false}
73+
grammar={atom.grammars.selectGrammarWithScore(
74+
buffer.getPath(),
75+
buffer.getText(),
76+
)}>
7277

7378
{this.props.config.get('github.showDiffIconGutter') && (
7479
<Gutter name="diff-icons" priority={1} type="line-number" className="icons" labelFn={blankLabel} />

0 commit comments

Comments
 (0)