Use display layers facility of text-buffer; delete all the code they replace #11414
Conversation
Markers are still translating via the DisplayBuffer, but that will change when display markers are moved into DisplayLayers.
I’m creating the DisplayLayer in the DisplayBuffer. In places where our API deviates from DisplayBuffer, I’ll use the DisplayLayer directly from as a property of TextEditor. Otherwise I’ll continue to delegate from the DisplayLayer into the DisplayLayer to minimize impact until the DisplayBuffer can be removed entirely.
This causes DisplayLayer to emit change events when syntax is updated asynchronously.
# Conflicts: # package.json # src/display-buffer.coffee # src/text-editor.coffee # src/tokenized-buffer.coffee
Calling ::updateHorizontalDimensions might cause the editor vertical coordinates (e.g. height, scroll top) to change, so we need to fetch lines again from `DisplayLayer`.
Yeah, seems like master exhibits the same behavior too: I think we explicitly disabled autoscrolling on mouse click because the resulting UX is somewhat worse (e.g. clicking on a visible character which is close to the left margin of the rendered area causes the editor to scroll). Maybe we need finer grained control over autoscroll, but I'd say to address this on a separate pull-request. Thanks for the heads-up, @50Wliu! |
...because the only possible scenario when a logical position in a text node cannot be found is when the requested pixel position is exactly at the end of the node.
Yup, fixed. Thanks! |
…because we're handling that behavior in `TextEditor` and `DisplayLayer` now.
@as-cii 👋 I was testing find & replace (in buffer) and came upon this error message. Then, I switched to find & replace in project and got an issue with mini map (which seems to be known?) but trying to reproduce it and it isn't happening again (minimap is working fine now) |
# Conflicts: # src/text-editor.coffee
👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 👏 |
I'm working on catching-up displayLayer change in my vim-mode-plus package t9md/atom-vim-mode-plus#269. Noticed two thing. Deprecation warning when I pass persistent option like blow.Reported to atom/text-buffer#154 editor.markBufferRange editor.getSelectedBufferRange(),
invalidate: 'never'
persistent: false Text wrap point diff when editor.setEditorWidthInChars()Not sure this is intended of not. Noticed by some failing spec(checking behavior in wrapped line). Maybe related to this commit? Here minimum spec to reproduce describe "Reproduce wrap diff", ->
it "wrap line diff with 1.9.0-dev-d06da3f and 1.8.3-beta3", ->
editor = null
waitsForPromise ->
atom.workspace.open(null).then (_editor) ->
editor = _editor
editor.setSoftWrapped(true)
editor.setEditorWidthInChars(10)
editor.setDefaultCharWidth(1)
editor.setText """
1st line of buffer
2nd line of buffer, Very long line
3rd line of buffer
5th line of buffer\n
"""
runs ->
{inspect} = require 'util'
console.log atom.appVersion
lineTexts = (editor.lineTextForScreenRow(screenRow) for screenRow in [0..4])
console.log inspect(lineTexts)
# v1.8.0-beta3
# [ '1st line ',
# 'of buffer',
# '2nd line ',
# 'of buffer, ',
# 'Very long ' ]
# 1.9.0-dev-d06da3f
# [ '1st line ', 'of buffer', '2nd line ', 'of ', 'buffer, ' ]
|
Yes, while in the middle of redesigning this part of Atom, we took some time to revisit how lines are soft-wrapped so that edits to the buffer could have been displayed in a very explicit manner to the user. In the specific case you've mentioned, Atom notices that |
So new wrapping strategy is more intelligent from humans expectation viewpoin. |
This PR replaces a bunch of old and twisty code in
TextEditor
with usage of a new facility in thetext-buffer
library introduced in atom/text-buffer#149. You can read that pull request for more information about what replaces all the code we're deleting here.