         userContentController.add(self, name: messageHandlerKeyReplace)
         
         webView.evaluateJavaScript("""
-            var replaceText = editor.getRange({line: \(newLocationFrom.line), ch: \(newLocationFrom.ch)}, {line: \(newLocationTo.line), ch: \(newLocationTo.ch)})
+                var replaceText = editor.getRange({line: \(newLocationFrom.line), ch: \(newLocationFrom.ch)}, {line: \(newLocationTo.line), ch: \(newLocationTo.ch)})
                 window.webkit.messageHandlers.\(messageHandlerKeyReplace).postMessage(replaceText)
+                true
             """) { (result, error) in
                 
                 replacedTextExpectation.fulfill()

                var line = editor.state.search.posFrom.line
                var ch = editor.state.search.posFrom.ch
                window.webkit.messageHandlers.\(messageHandlerKeyCurrentSearchLocation).postMessage({'\(cursorLineKey)': line, '\(cursorCharacterKey)': ch})
            """) { (result, error) in
                
                currentSearchLocationExpectation.fulfill()

        webView.evaluateJavaScript("""
                var line = editor.state.search.posFrom.line
                var ch = editor.state.search.posFrom.ch
                window.webkit.messageHandlers.\(messageHandlerKeyNextSearchLocation).postMessage({'\(cursorLineKey)': line, '\(cursorCharacterKey)': ch})
                true
            """) { (result, error) in
                
                nextSearchLocationExpectation.fulfill()
