File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ const findDOMNode = ReactDOM.findDOMNode;
4
4
const className = require ( 'classnames' ) ;
5
5
const debounce = require ( 'lodash.debounce' ) ;
6
6
7
+ function normalizeLineEndings ( str ) {
8
+ if ( ! str ) return str ;
9
+ return str . replace ( / \r \n | \r / g, '\n' ) ;
10
+ }
11
+
7
12
const CodeMirror = React . createClass ( {
8
13
propTypes : {
9
14
className : React . PropTypes . any ,
@@ -50,7 +55,7 @@ const CodeMirror = React.createClass({
50
55
}
51
56
} ,
52
57
componentWillReceiveProps : function ( nextProps ) {
53
- if ( this . codeMirror && nextProps . value !== undefined && this . codeMirror . getValue ( ) !== nextProps . value ) {
58
+ if ( this . codeMirror && nextProps . value !== undefined && normalizeLineEndings ( this . codeMirror . getValue ( ) ) !== normalizeLineEndings ( nextProps . value ) ) {
54
59
if ( this . props . preserveScrollPosition ) {
55
60
var prevScrollPosition = this . codeMirror . getScrollInfo ( ) ;
56
61
this . codeMirror . setValue ( nextProps . value ) ;
You can’t perform that action at this time.
0 commit comments