Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Lines number after setText ('change' event) is broken #1356

Closed
tucnak opened this Issue · 3 comments

2 participants

@tucnak

If I call

editor.getSession().setValue('%1')

Also, I have a handler:

editor.on('change', function() {
    var newLines = editor.session.getLength();
    if (newLines != property("lines")) { // property is a storage function
        property("lines", newLines);
        Novile.onLinesChanged(newLines);
    }
});

Application's debug output:

[1] Lines number: 2. Text is "'use strict';
"
[2] Lines number: 1047. Text is "'use strict';

////////////////////////////////////

/**
 * @ngdoc function

...

after one setText call and code listed below. So, 'change' event is called twice (no idea why) and shows 2 lines always ('use strict' + \n) before real number of lines in the document

@nightwing
Owner

Change event is dispatched synchronously during each part operation, setValue creates multiple change events one for removing old text and one for inserting.
Operations inserting multiple lines also will create several change events

@tucnak

@nightwing How can I handle visual changes, like changing the text or # of lines?

@nightwing
Owner

It depends on what exactly you need, but setTimeout can work see http://jsbin.com/ojijeb/67/edit

@tucnak tucnak closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.