Ace editor selects all text on assignment

I’m working on a small app that manipulates text while it’s being edited. My issue is that whenever I update text in the Ace editor .value param, all the text gets highlighted.
v1 - Google Chrome 2021-08-30 16-28-12

Based on the the API, Ace provides a gotoLine method that let’s you move the cursor to the specified row/column. Unfortunately, I couldn’t figure out how to run this method from Panel. Any tips would be extremely appreciated.

Minimal example app that replaces any instances of ‘foo’ with ‘bar’ every three seconds:

import panel as pn
import param

class Editor(param.Parameterized):
    def __init__(self, **kwrgs):

        self.editor = pn.widgets.Ace()

        self.cb = pn.state.add_periodic_callback(self.update_editor, period=3000)


    def update_editor(self):
        s = self.editor.value
        s = "bar".join(s.split("foo"))
        self.editor.value = s

    def view(self):
        template = pn.template.FastListTemplate(

        return template

def get_editor():
    editor = Editor()
    return editor.view()

# Start server
pn.serve(get_editor, port=9999, websocket_origin="*", verbose=True)