[solved] Deprecations: "This is now a view method. Call TextEditorElement::... instead"



I would like to remove a bunch of deprecation warnings from a package.

Deprecation cop complains about: pixelRectForScreenRange(), getScrollTop(), setScrollTop(), getScrollBottom() and getHeight().

All of them are called on an object created by atom.workspace.getActiveTextEditor().

I guess this is the deprecated call. But I can’t find out by what other call it should be replaced. I tried to replace it with atom.views.getView(textEditor) (not sure it makes sense: I’m no atom expert), it removes the deprecations warnings but then I get an error: Uncaught ReferenceError: textEditor is not defined.

What’s the correct way to remove these deprecation warnings?


I think you could try to call it on atom.workspace.getActiveTextEditor().element.


Tried, but this is not the solution, it raises now:

editor.screenPositionForBufferPosition is not a function


This method is for the model, not the element. Use the element only with the five methods that are signaled as deprecated.


Oh sorry I didn’t even notice this one was not among the ones I did mention in the first post.

I keep you informed once I have done the modifications.


Seems to work fine! Many thanks!