Constrains the active line hover to the start/end of a line

This commit is contained in:
Eric Amodio
2017-05-22 16:17:20 -04:00
parent 19e523d6e4
commit e1b1b737d9

View File

@@ -326,12 +326,18 @@ export class BlameActiveLineController extends Disposable {
} }
} }
let decorationOptions: DecorationOptions | undefined = undefined; let decorationOptions: [DecorationOptions] | undefined = undefined;
switch (activeLine) { switch (activeLine) {
case 'both': case 'both':
case 'inline': case 'inline':
decorationOptions = { const range = editor.document.validateRange(new Range(blameLine.line + offset, 0, blameLine.line + offset, 1000000));
range: editor.document.validateRange(new Range(blameLine.line + offset, 0, blameLine.line + offset, 1000000)), decorationOptions = [
{
range: range.with({
start: range.start.with({
character: range.end.character
})
}),
hoverMessage: hoverMessage, hoverMessage: hoverMessage,
renderOptions: { renderOptions: {
after: { after: {
@@ -348,19 +354,31 @@ export class BlameActiveLineController extends Disposable {
} }
} }
} as DecorationInstanceRenderOptions } as DecorationInstanceRenderOptions
} as DecorationOptions; } as DecorationOptions,
// Add a hover decoration to the area between the start of the line and the first non-whitespace character
{
range: range.with({
end: range.end.with({
character: editor.document.lineAt(range.end.line).firstNonWhitespaceCharacterIndex
})
}),
hoverMessage: hoverMessage
} as DecorationOptions
];
break; break;
case 'hover': case 'hover':
decorationOptions = { decorationOptions = [
{
range: editor.document.validateRange(new Range(blameLine.line + offset, 0, blameLine.line + offset, 1000000)), range: editor.document.validateRange(new Range(blameLine.line + offset, 0, blameLine.line + offset, 1000000)),
hoverMessage: hoverMessage hoverMessage: hoverMessage
} as DecorationOptions; } as DecorationOptions
];
break; break;
} }
if (decorationOptions !== undefined) { if (decorationOptions !== undefined) {
editor.setDecorations(activeLineDecoration, [decorationOptions]); editor.setDecorations(activeLineDecoration, decorationOptions);
} }
} }
} }