codemirror file view: Fix non-extension decorations
Created by: fkling
While working on deprecating the extension API @philipp-spiess discovered that blame view data wasn't shown properly when it was enabled.
The reason for this was that the view plugin used to generate the CodeMirror decorations didn't do that when the plugin was instantiated. I can only assume that with extensions enabled it "worked" because the plugin was instantiated prior to receiving the git blame data. But when extensions are disabled the plugin is only created once the data is provided.
This also fixes a subtle bug with how the gutter renders selected lines.
Demo:
https://user-images.githubusercontent.com/179026/184391821-392d3fd3-a6c0-4445-ac76-de0af43ea2f3.mp4
The second commit makes a change to how blame information is computed.
While working on this I noticed that selecting a line (and thus changing
the URL) caused new decorations data to be fetch/generated.
I changed the implementation of useBlameDecorations
to only recompute
the data when necessary. The only consequence is that the relative time
won't be updated anymore on rerenders, but that's probably fine?
Test plan
- Enable
"extensionsAsCoreFeatures": true
in user settings. - Comment out the
sourcegraphExtensions(...)
call inCodeMirrorBlob
- Open a file and toggle the git button
App preview:
Check out the client app preview documentation to learn more.