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;
44const className = require ( 'classnames' ) ;
55const debounce = require ( 'lodash.debounce' ) ;
66
7+ function normalizeLineEndings ( str ) {
8+ if ( ! str ) return str ;
9+ return str . replace ( / \r \n | \r / g, '\n' ) ;
10+ }
11+
712const CodeMirror = React . createClass ( {
813 propTypes : {
914 className : React . PropTypes . any ,
@@ -50,7 +55,7 @@ const CodeMirror = React.createClass({
5055 }
5156 } ,
5257 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 ) ) {
5459 if ( this . props . preserveScrollPosition ) {
5560 var prevScrollPosition = this . codeMirror . getScrollInfo ( ) ;
5661 this . codeMirror . setValue ( nextProps . value ) ;
You can’t perform that action at this time.
0 commit comments