inside the docChanged event. However I am getting the older line height as in height from previous view.
I am not sure if this a bug or I am doing something wrong.
I think when a change occurs, and your function is called for the update, the DOM hasn’t been flushed and the changes haven’t been yet applied to the DOM which is when the heights gets measured.
What I usually do is to use a view.requestMeasure() and do things in the callbacks from there.
Assuming this code is running in an update listener, the DOM has been written when it runs, but not re-measured (to avoid layout trashing), so indeed, if you need accurate DOM geometry info, requestMeasure is what you want.
view.requestMeasure() worked for me. However the read and write functions are called on every change including moving the cursor position. Is there a way to limit calling it only when any line height changes?
They are called whenever you call requestMeasure, so this is under your control. You could check update.heightChanged and only measure when that is true.
Thanks. This narrowed the calls down to anytime doc changes. However not sure if it a bug but update.heightChanged returns true for every doc changed, not just heightChanged.