Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Use logical coordinates in DisplayBuffer #8905

Merged
merged 61 commits into from
Sep 26, 2015

Conversation

as-cii
Copy link
Contributor

@as-cii as-cii commented Sep 23, 2015

This PR moves all the code that handles pixel positions into TextEditorPresenter, where it belongs. This is part of the effort to merge #8811, as we realized we needed the DisplayBuffer to be clean before proceeding with measurements.

This refactoring was quite big, so I'd ❤️ to gather some feedback on the changes I have made (both on code quality and regressions).

What's missing:

  • Fix missing failing specs.
  • Fix package specs (by shimming the original API).
  • Maintain a scroll queue to preserve scroll history.
  • Serialize scroll state in terms of logical coordinates.
  • Confirm that packages work as expected.
  • Confirm that atom core works as expected.
  • Shim TextEditor APIs to use their TextEditorElement counterpart.
  • Fix discovered bugs.

Thanks! 🙇

/cc: @nathansobo @atom/feedback

@as-cii
Copy link
Contributor Author

as-cii commented Sep 25, 2015

Okay, the build is 💚 now and I think I have addressed all the concerns we had during our call. 🎉

I have found, however, a method on Marker which makes use of the display buffer's pixel conversion methods (i.e. Marker::getPixelRange) and a cursory search on GitHub showed that someone is actually using it 😞.

We cannot shim it to a corresponding method on the view, though, as we don't have any reference to TextEditor in DisplayBuffer: passing a TextEditor instance when constructing DisplayBuffer seems like a bad move to me (other than being an unhealthy dependency, I think we'd have serialization issues) so I went ahead and simply deleted it in a027772 and 7cd318f.

If we want to keep it, I think the only option would be to deprecate it for a few versions and then delete it afterwards (so that package developers have some time to upgrade). On the other hand I'd ❤️ to clean the DisplayBuffer as soon as possible... What do you think?

Other than that, I think this is ready to 🚢! @nathansobo: please, have one last 👀.

Thanks everyone for the feedback! 🙏

@nathansobo
Copy link
Contributor

and a cursory search on GitHub showed that someone is actually using it

It wasn't in the public API right? How popular is the package in question? Maybe we should open an issue or even open a PR if it's a simple fix.


iterator = @model.tokenizedLineForScreenRow(row).getTokenIterator()
while iterator.next()
charWidths = @getScopedCharacterWidths(iterator.getScopes())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's going to be so great to drop this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! 🎆

@nathansobo
Copy link
Contributor

Gave this a quick scan. Ultimately if tests are green and the structure hasn't changed beyond our discussion, I'm good to merge once we drop deprecated methods from the docs.

@as-cii
Copy link
Contributor Author

as-cii commented Sep 25, 2015

It wasn't in the public API right? How popular is the package in question? Maybe we should open an issue or even open a PR if it's a simple fix.

Nope, the method wasn't in the public API. The package in question is color-picker but I think the fix is straightforward enough to deserve a PR. I'll do that shortly and 🚢 this PR afterwards.

Thanks, @nathansobo!

as-cii added a commit that referenced this pull request Sep 26, 2015
@as-cii as-cii merged commit f17767a into master Sep 26, 2015
@as-cii as-cii deleted the as-display-buffer-logical-coordinates branch September 26, 2015 16:05
@nathansobo
Copy link
Contributor

💥🎉🇮🇹

@maxbrunsfeld
Copy link
Contributor

Awesome!

@maxbrunsfeld
Copy link
Contributor

@as-cii, apparently our internal CI goes red when deprecated methods are called by core or bundled packages. I actually didn't know this either, until now, but I guess it makes sense, because we don't want the somewhat-expensive Grim.deprecate calls to be happening in the next release. I temporarily commented out the Grim.deprecate calls that you added in TextEditor, just to get CI green.

When you get a chance, could you update core and bundled packages to use the new APIs? The deprecations occurred in these tests:

  • find-and-replace
  • symbols-view
  • wrap-guide
  • atom core
    • ::page{Up,Down}
    • ::selectPage{Up,Down}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants