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


#1

Hello,

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?


#2

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


#3

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

editor.screenPositionForBufferPosition is not a function


#4

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


#5

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.


#6

Seems to work fine! Many thanks!