Skip to content
This repository was archived by the owner on Apr 1, 2020. It is now read-only.

Conversation

akinsho
Copy link
Member

@akinsho akinsho commented Jul 27, 2018

Given the functionality was almost there I decided to try my hands at a git blame layer. The idea being to emulate a little the vscode GitLens git blame functionality. What this adds is a git blame per line, when the user is resting on the line like the hover tool tip.

It renders inline if there is space otherwise it renders above the line in a tooltip like container.

blame_layer2

EDIT: Removed the popup as this was in an awkward position (competing with the hover tooltip) instead the layer now renders the highlight on the given line if the space is too small it begins to truncate the blame summary if still too large it renders the summary in the earliest previous empty space (possibly overkill to have so many layers to try and preserve rendering on depending on screen space but as someone who works on a laptop it seemed worth the effort)

Outstanding:

  • Tests
  • Configuration: experimental flag, off by default, enabled: auto i.e. per new line after a wait of a configurable amount of time, manual i.e. triggered manually per line via a key binding

@codecov
Copy link

codecov bot commented Jul 27, 2018

Codecov Report

Merging #2469 into master will increase coverage by 0.36%.
The diff coverage is 68.53%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2469      +/-   ##
=========================================
+ Coverage   43.83%   44.2%   +0.36%     
=========================================
  Files         343     344       +1     
  Lines       13716   13886     +170     
  Branches     1800    1829      +29     
=========================================
+ Hits         6013    6138     +125     
- Misses       7464    7508      +44     
- Partials      239     240       +1
Impacted Files Coverage Δ
...src/Services/Configuration/DefaultConfiguration.ts 87.5% <ø> (ø) ⬆️
.../Services/VersionControl/VersionControlProvider.ts 100% <ø> (ø) ⬆️
browser/src/UI/components/VersionControl/Help.tsx 90.47% <100%> (ø) ⬆️
...src/Editor/NeovimEditor/NeovimBufferLayersView.tsx 80% <100%> (ø) ⬆️
ui-tests/mocks/Utility.ts 100% <100%> (ø) ⬆️
...owser/src/UI/components/VersionControl/Commits.tsx 94.11% <100%> (-0.89%) ⬇️
browser/src/UI/components/common.ts 92.59% <100%> (+0.13%) ⬆️
...wser/src/Editor/NeovimEditor/BufferLayerManager.ts 62.96% <100%> (+49.91%) ⬆️
browser/src/Editor/NeovimEditor/NeovimEditor.tsx 9.36% <50%> (ø) ⬆️
.../Services/VersionControl/VersionControlManager.tsx 55.39% <66.66%> (+0.5%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2c03e73...ea19dcc. Read the comment docs.

@akinsho akinsho changed the title [WIP] Feature/git blame layer Feature/git blame layer Jul 28, 2018
@bryphe
Copy link
Member

bryphe commented Jul 28, 2018

Very cool! 😄

@akinsho
Copy link
Member Author

akinsho commented Jul 28, 2018

@bryphe thanks 👍 the layer api is really nice, making layers really fun to create, hence my various layers, its such a cool way to add extra functionality 😍

@akinsho akinsho requested review from CrossR and bryphe July 29, 2018 08:34
akinsho added 24 commits July 29, 2018 23:31
add ability to run in manual mode require a binding to be hit to show the blame
add comments to explain, also fix out of bounds function
query only a single line at a time and update state with next props
@akinsho akinsho force-pushed the feature/git-blame-layer branch from 98729d4 to 7c10e8c Compare August 2, 2018 21:37
@@ -69,6 +69,13 @@ export class BufferLayerManager {
}
}

const getInstance = (() => {
Copy link
Member

Choose a reason for hiding this comment

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

Just curious - why is this wrapped in an IIFE? Is there a functionaility reason for it?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's to encapsulate the instance inside of the function and just return a function that provides access to it,

So rather than

	let instance = new BufferLayerManager() // global variable
	export getInstance = () => instance

	const getInstance = (() => {
		const instance = new Manager() // scoped to the IIFE and accessed via the closure
		return () => {
			return instance
		}

Its a very small distinction I've just been bitten by global vars previously and try to always find ways around them.

}

public getLastEmptyLine() {
const { cursorLine, visibleLines, topBufferLine } = this.props
Copy link
Member

Choose a reason for hiding this comment

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

Nice work getting all this info from the buffer layer API, it's another great example 💯

@@ -42,6 +63,7 @@ export interface VersionControlProvider {
canHandleWorkspace(dir?: string): Promise<boolean>
getStatus(): Promise<StatusResult | void>
getRoot(): Promise<string | void>
getBlame(args: BlameArgs): Promise<Blame>
Copy link
Member

Choose a reason for hiding this comment

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

Cool! I like that this is abstracted out and that the layer itself doesn't need to know about Git - just about the Blame / BlameArgs.

@bryphe
Copy link
Member

bryphe commented Aug 2, 2018

Change looks good to me! Great work @akin909 - really like the way you architected this functionality.

Minor feedback on the look - I'm wondering if it makes sense to right-align the blame text?

image

But I'm fine if that comes in separately, we can always tweak the styling later 👍

@akinsho
Copy link
Member Author

akinsho commented Aug 2, 2018

@bryphe thanks for reviewing 👍, re the look I was basically copying

vscodes' GitLens plugin
screen shot 2018-08-03 at 00 17 48

Having caught a peek of it looking at a colleagues setup, and also because I though another popup would be too cluttered but am open to suggestions (I don't have any alternate ideas at all myself)

@akinsho akinsho merged commit 66a13f5 into onivim:master Aug 2, 2018
@akinsho akinsho deleted the feature/git-blame-layer branch August 2, 2018 23:23
@akinsho akinsho restored the feature/git-blame-layer branch August 2, 2018 23:23
@akinsho akinsho deleted the feature/git-blame-layer branch August 2, 2018 23:23
@feltech
Copy link
Contributor

feltech commented Aug 24, 2018

I enabled this a few days ago and it's working wonderfully. I really like how it finds nearby whitespace to render into - much less invasive than a pop-up that obscures code, or a split that reduces available window width.

My one issue is that I use Oni with two vertical splits. This doesn't leave much room, and most of the space available is taken up with the author and time, when for me the message is more useful.

Perhaps a future tweak would be some configuration as to the ordering of the fields? Maybe that can already be done with "experimental.vcs.blame.mode" config option? I haven't had chance to dive into the code to see what that does, though.

@akinsho akinsho restored the feature/git-blame-layer branch October 1, 2018 09:35
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.

3 participants