<commit_before>import editor from './editor'
import { connect } from 'react-redux'
import { updateFunctionContent } from '../store/fileStorage'

const FunctionsView = (React) => {
    const Editor = editor(React)
    let selectState = ({fileStorage}) => {
        let functions = fileStorage[1].functions.concat(fileStorage[0].functions)
        return {
            functions
        }
    }

    return connect(selectState)(({functions, dispatch}) => {
        let editorStyle = {
            border: '2px solid steelblue',
            marginBottom: 4
        }
        let texts = functions.map(function (node, i) {
            let onContentChange = ({value}) => {
                dispatch(updateFunctionContent({
                    oldFunction: node,
                    newContent: value
                }))
            }
            return <div key={ node.customId }>
                       <div>unique id:
                           { ' ' }
                           { node.customId }
                       </div>
                       <Editor editorStyle={ editorStyle } content={ node.text } onContentChange={ onContentChange } />
                   </div>
        })
        return <div>
                   { texts }
               </div>
    })
}

export default FunctionsView<commit_msg>don't update on formatted text<commit_after>import editor from './editor'
import { connect } from 'react-redux'
import { updateFunctionContent } from '../store/fileStorage'

const FunctionsView = (React) => {
    const Editor = editor(React)
    let selectState = ({fileStorage}) => {
        let functions = fileStorage[1].functions.concat(fileStorage[0].functions)
        return {
            functions
        }
    }

    return connect(selectState)(({functions, dispatch}) => {
        let editorStyle = {
            border: '2px solid steelblue',
            marginBottom: 4
        }
        let texts = functions.map(function (node, i) {
            let onContentChange = ({value}) => {
                if (value === node.text) {
                    // content was changed by setting reformatted text
                    return
                }
                dispatch(updateFunctionContent({
                    oldFunction: node,
                    newContent: value
                }))
            }
            return <div key={ node.customId }>
                       <div>unique id:
                           { ' ' }
                           { node.customId }
                       </div>
                       <Editor editorStyle={ editorStyle } content={ node.text } onContentChange={ onContentChange } />
                   </div>
        })
        return <div>
                   { texts }
               </div>
    })
}

export default FunctionsView
{'fraction_non_alphanumeric': 0.10531991373112869, 'fraction_numerical': 0.002875629043853343, 'mean_word_length': 1.3685106382978725, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '346334', 'n_tokens_mistral': 678, 'n_tokens_neox': 647, 'n_words': 160}