diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index 68157530..9920cf41 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -201,6 +201,7 @@ export default class CodeEditor extends React.Component { this.editor.setValue(this.props.value) this.editor.clearHistory() this.editor.on('change', this.changeHandler) + this.editor.refresh() } setValue (value) { diff --git a/browser/main/Detail/SnippetNoteDetail.js b/browser/main/Detail/SnippetNoteDetail.js index 66c0b673..d80ccdae 100644 --- a/browser/main/Detail/SnippetNoteDetail.js +++ b/browser/main/Detail/SnippetNoteDetail.js @@ -250,17 +250,21 @@ class SnippetNoteDetail extends React.Component { } deleteSnippetByIndex (index) { - let snippets = this.state.note.snippets.slice() - snippets.splice(index, 1) - this.state.note.snippets = snippets - let snippetIndex = this.state.snippetIndex >= snippets.length - ? snippets.length - 1 - : this.state.snippetIndex - this.setState({ - note: this.state.note, - snippetIndex + this.setState(() => { + let snippets = this.state.note.snippets.slice() + snippets.splice(index, 1) + let note = Object.assign({}, this.state.note, {snippets}) + let snippetIndex = this.state.snippetIndex >= snippets.length + ? snippets.length - 1 + : this.state.snippetIndex + + return { + note, + snippetIndex + } }, () => { this.save() + this.refs['code-' + this.state.snippetIndex].reload() }) }