4

Is there anything like

editor.getSession.trigger('change')

the reason I want this is because the editor goes in and out of new, so when It comes back into view I need it to do its normal 'change' thing, but I dont want to wait for user input?

Currently I have

editor.getSession().on('change', function(){
    editorChangeHandler()
})

and I just recall

        editorChangeHandler()

when I need to, but editor.getSession.trigger('change') is much nicer.

2 Answers 2

3

editor.session._emit('change') would trigger editorChangeHandler, but fake change event will break undo history.

Sign up to request clarification or add additional context in comments.

2 Comments

I tried this approach and got an error ace.js:7973 Uncaught TypeError: Cannot read property 'row' of undefined
I had to do something like: editor.getSession()._emit('change', {start:{row:0,column:0},end:{row:0,column:0},action:'insert',lines: []})
0

the reason I want this is because the editor goes in and out of new, so when It comes back into view I need it to do its normal 'change' thing, but I dont want to wait for user input?

You may try an alternative solution to the case using underscore.js.

Change:

editor.getSession().on('change', function(){
    editorChangeHandler()
})

to:

editor.getSession().on('change', _.debounce(function() {
    editorChangeHandler()
}, 100))

when you trigger a change it like:

editor.setValue('my change..');

then it will behave like your wish:

editor.getSession.trigger('change')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.