{"action":"created","issue":{"url":"https://api.github.com/repos/atom/atom/issues/10699","repository_url":"https://api.github.com/repos/atom/atom","labels_url":"https://api.github.com/repos/atom/atom/issues/10699/labels{/name}","comments_url":"https://api.github.com/repos/atom/atom/issues/10699/comments","events_url":"https://api.github.com/repos/atom/atom/issues/10699/events","html_url":"https://github.com/atom/atom/issues/10699","id":131610394,"number":10699,"title":"Proposal: API enhancement for editors with block decorations","user":{"login":"abe33","id":247140,"avatar_url":"https://avatars.githubusercontent.com/u/247140?v=3","gravatar_id":"","url":"https://api.github.com/users/abe33","html_url":"https://github.com/abe33","followers_url":"https://api.github.com/users/abe33/followers","following_url":"https://api.github.com/users/abe33/following{/other_user}","gists_url":"https://api.github.com/users/abe33/gists{/gist_id}","starred_url":"https://api.github.com/users/abe33/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abe33/subscriptions","organizations_url":"https://api.github.com/users/abe33/orgs","repos_url":"https://api.github.com/users/abe33/repos","events_url":"https://api.github.com/users/abe33/events{/privacy}","received_events_url":"https://api.github.com/users/abe33/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/atom/atom/labels/enhancement","name":"enhancement","color":"bfd4f2"},{"url":"https://api.github.com/repos/atom/atom/labels/proposal","name":"proposal","color":"c7def8"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-02-05T10:46:32Z","updated_at":"2016-03-22T15:01:34Z","closed_at":null,"body":"I fiddled with the block decoration features to check how this would affect the minimap and as I suspected it completely breaks the sync between the two views.\r\n\r\nThe biggest concern I have for the moment is that there is no public API to get the height and the y position of a line with a block decoration attached. Since I guess these are quite costly operations that are already handled by the editor's view I would expect it to expose these informations publicly so that we don't need to traverse all the editor's layers and decorations to compute these values. \r\n\r\nAnother approach would be to have two sets of scroll values, one that account for the decorations and one that doesn't. For instance with a block decoration of 100px height at one line, the first method would return a scroll height equal to the height of all lines + 100 and the other one would return the just the height of all lines. Same goes for the scroll position, the first one would returns the scroll as it's used in the view, the other one would return the scroll position ignoring the block decoration (clamping the value to the start/end y of the line depending on whether the block is displayed before or after the line).\r\n\r\nA third possibility is to have a scroll position defined as a couple of value: the first visible line index and a position within the line (in the range 0-1). If we have access to the line y position and height through an API, we can compute the corresponding scroll top, or map this to any other type of grid and still be in complete sync with the editor.\r\n\r\nAnother concern for the minimap is that block decorations breaks the assumption that an editor's lines all fit on a predefined grid. It means that I can no longer use a ratio to transpose a line height and position and still get an integer value at the end - let say a line takes 17px in the editor, and 3px in the minimap, I can always assume that line 11 will be at y=30px in the minimap. Now with block decorations, a line can have an arbitrary height, which means that if I apply this ratio to get the line height I'll probably end up with a decimal value. And as the minimap is using a canvas, decimal values need to be avoided at all cost to preserve the crispness of the minimap render. To workaround that I would probably need to map every line heights from the editor to a rounded value more suited to the minimap. But same thing here, it would better if I could avoid traversing all the editor's lines to make this computations. \r\n\r\nHow do you feel about this?\r\n\r\ncc/ @nathansobo, @as-cii\r\n"},"comment":{"url":"https://api.github.com/repos/atom/atom/issues/comments/199854977","html_url":"https://github.com/atom/atom/issues/10699#issuecomment-199854977","issue_url":"https://api.github.com/repos/atom/atom/issues/10699","id":199854977,"user":{"login":"abe33","id":247140,"avatar_url":"https://avatars.githubusercontent.com/u/247140?v=3","gravatar_id":"","url":"https://api.github.com/users/abe33","html_url":"https://github.com/abe33","followers_url":"https://api.github.com/users/abe33/followers","following_url":"https://api.github.com/users/abe33/following{/other_user}","gists_url":"https://api.github.com/users/abe33/gists{/gist_id}","starred_url":"https://api.github.com/users/abe33/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abe33/subscriptions","organizations_url":"https://api.github.com/users/abe33/orgs","repos_url":"https://api.github.com/users/abe33/repos","events_url":"https://api.github.com/users/abe33/events{/privacy}","received_events_url":"https://api.github.com/users/abe33/received_events","type":"User","site_admin":false},"created_at":"2016-03-22T15:01:34Z","updated_at":"2016-03-22T15:01:34Z","body":"> Could you profile what's slow in the benchmark you have performed and post it here\r\n\r\nSure things, here the CPU profile: \r\nhttps://gist.github.com/abe33/28b62272790fc591e964"}}