Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💄 Diff decorators - remove registerThemingParticipant #164889

Merged
merged 1 commit into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 1 addition & 80 deletions src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { URI } from 'vs/base/common/uri';
import { ISCMService, ISCMRepository, ISCMProvider } from 'vs/workbench/contrib/scm/common/scm';
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
import { registerThemingParticipant, IColorTheme, ICssStyleCollector, themeColorFromId, IThemeService, ThemeIcon } from 'vs/platform/theme/common/themeService';
import { IColorTheme, themeColorFromId, IThemeService, ThemeIcon } from 'vs/platform/theme/common/themeService';
import { editorErrorForeground, registerColor, transparent } from 'vs/platform/theme/common/colorRegistry';
import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from 'vs/editor/browser/editorBrowser';
import { registerEditorAction, registerEditorContribution, ServicesAccessor, EditorAction } from 'vs/editor/browser/editorExtensions';
Expand Down Expand Up @@ -52,7 +52,6 @@ import { TextCompareEditorActiveContext } from 'vs/workbench/common/contextkeys'
import { IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';
import { IChange } from 'vs/editor/common/diff/smartLinesDiffComputer';
import { Color } from 'vs/base/common/color';
import { editorGutter } from 'vs/editor/common/core/editorColorRegistry';
import { Iterable } from 'vs/base/common/iterator';

class DiffActionRunner extends ActionRunner {
Expand Down Expand Up @@ -1508,81 +1507,3 @@ export class DirtyDiffWorkbenchController extends Disposable implements ext.IWor
}

registerEditorContribution(DirtyDiffController.ID, DirtyDiffController);

registerThemingParticipant((theme: IColorTheme, collector: ICssStyleCollector) => {
const editorGutterBackgroundColor = theme.getColor(editorGutter);
const editorGutterModifiedBackgroundColor = theme.getColor(editorGutterModifiedBackground);

const getLinearGradient = (color: Color): string => {
return `-45deg, ${color} 25%, ${editorGutterBackgroundColor} 25%, ${editorGutterBackgroundColor} 50%, ${color} 50%, ${color} 75%, ${editorGutterBackgroundColor} 75%, ${editorGutterBackgroundColor}`;
};

if (editorGutterBackgroundColor && editorGutterModifiedBackgroundColor) {
collector.addRule(`
.monaco-editor .dirty-diff-modified {
border-left-color: ${editorGutterModifiedBackgroundColor};
border-left-style: solid;
transition: opacity 0.5s;
}
.monaco-editor .dirty-diff-modified:before {
background: ${editorGutterModifiedBackgroundColor};
}
.monaco-editor .dirty-diff-modified-pattern {
background-image: linear-gradient(${getLinearGradient(editorGutterModifiedBackgroundColor)});
background-repeat: repeat-y;
transition: opacity 0.5s;
}
.monaco-editor .dirty-diff-modified-pattern:before {
background-image: linear-gradient(${getLinearGradient(editorGutterModifiedBackgroundColor)});
transform: translateX(3px);
}
.monaco-editor .margin:hover .dirty-diff-modified,
.monaco-editor .margin:hover .dirty-diff-modified-pattern {
opacity: 1;
}
`);
}

const editorGutterAddedBackgroundColor = theme.getColor(editorGutterAddedBackground);
if (editorGutterBackgroundColor && editorGutterAddedBackgroundColor) {
collector.addRule(`
.monaco-editor .dirty-diff-added {
border-left-color: ${editorGutterAddedBackgroundColor};
border-left-style: solid;
transition: opacity 0.5s;
}
.monaco-editor .dirty-diff-added:before {
background: ${editorGutterAddedBackgroundColor};
}
.monaco-editor .dirty-diff-added-pattern {
background-image: linear-gradient(${getLinearGradient(editorGutterAddedBackgroundColor)});
background-repeat: repeat-y;
transition: opacity 0.5s;
}
.monaco-editor .dirty-diff-added-pattern:before {
background-image: linear-gradient(${getLinearGradient(editorGutterAddedBackgroundColor)});
transform: translateX(3px);
}
.monaco-editor .margin:hover .dirty-diff-added,
.monaco-editor .margin:hover .dirty-diff-added-pattern {
opacity: 1;
}
`);
}

const editorGutteDeletedBackgroundColor = theme.getColor(editorGutterDeletedBackground);
if (editorGutteDeletedBackgroundColor) {
collector.addRule(`
.monaco-editor .dirty-diff-deleted:after {
border-left: 4px solid ${editorGutteDeletedBackgroundColor};
transition: opacity 0.5s;
}
.monaco-editor .dirty-diff-deleted:before {
background: ${editorGutteDeletedBackgroundColor};
}
.monaco-editor .margin:hover .dirty-diff-added {
opacity: 1;
}
`);
}
});
81 changes: 66 additions & 15 deletions src/vs/workbench/contrib/scm/browser/media/dirtydiffDecorator.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,69 @@
z-index: 5;
}

.monaco-editor .dirty-diff-glyph:before {
position: absolute;
content: '';
height: 100%;
width: 0;
left: -2px;
transition: width 80ms linear, left 80ms linear, transform 80ms linear;
}

/* Hide glyph decorations when inside the inline diff editor */
.monaco-editor.modified-in-monaco-diff-editor .margin-view-overlays > div > .dirty-diff-glyph {
display: none;
}

.monaco-editor .dirty-diff-added {
border-left-color: var(--vscode-editorGutter-addedBackground);
border-left-style: solid;
transition: opacity 0.5s;
}

.monaco-editor .dirty-diff-added:before {
background: var(--vscode-editorGutter-addedBackground);
}

.monaco-editor .dirty-diff-added-pattern {
background-image: linear-gradient(-45deg, var(--vscode-editorGutter-addedBackground) 25%, var(--vscode-editorGutter-background) 25%, var(--vscode-editorGutter-background) 50%, var(--vscode-editorGutter-addedBackground) 50%, var(--vscode-editorGutter-addedBackground) 75%, var(--vscode-editorGutter-background) 75%, var(--vscode-editorGutter-background));
background-repeat: repeat-y;
transition: opacity 0.5s;
}

.monaco-editor .dirty-diff-added-pattern:before {
background-image: linear-gradient(-45deg, var(--vscode-editorGutter-addedBackground) 25%, var(--vscode-editorGutter-background) 25%, var(--vscode-editorGutter-background) 50%, var(--vscode-editorGutter-addedBackground) 50%, var(--vscode-editorGutter-addedBackground) 75%, var(--vscode-editorGutter-background) 75%, var(--vscode-editorGutter-background));
transform: translateX(3px);
}

.monaco-editor .dirty-diff-modified {
border-left-color: var(--vscode-editorGutter-modifiedBackground);
border-left-style: solid;
transition: opacity 0.5s;
}

.monaco-editor .dirty-diff-modified:before {
background: var(--vscode-editorGutter-modifiedBackground);
}

.monaco-editor .dirty-diff-modified-pattern {
background-image: linear-gradient(-45deg, var(--vscode-editorGutter-modifiedBackground) 25%, var(--vscode-editorGutter-background) 25%, var(--vscode-editorGutter-background) 50%, var(--vscode-editorGutter-modifiedBackground) 50%, var(--vscode-editorGutter-modifiedBackground) 75%, var(--vscode-editorGutter-background) 75%, var(--vscode-editorGutter-background));
background-repeat: repeat-y;
transition: opacity 0.5s;
}

.monaco-editor .dirty-diff-modified-pattern:before {
background-image: linear-gradient(-45deg, var(--vscode-editorGutter-modifiedBackground) 25%, var(--vscode-editorGutter-background) 25%, var(--vscode-editorGutter-background) 50%, var(--vscode-editorGutter-modifiedBackground) 50%, var(--vscode-editorGutter-modifiedBackground) 75%, var(--vscode-editorGutter-background) 75%, var(--vscode-editorGutter-background));
transform: translateX(3px);
}

.monaco-editor .margin:hover .dirty-diff-added,
.monaco-editor .margin:hover .dirty-diff-added-pattern,
.monaco-editor .margin:hover .dirty-diff-modified,
.monaco-editor .margin:hover .dirty-diff-modified-pattern {
opacity: 1;
}

.monaco-editor .dirty-diff-deleted:after {
content: '';
position: absolute;
Expand All @@ -18,27 +81,15 @@
z-index: 9;
border-top: 4px solid transparent;
border-bottom: 4px solid transparent;
transition: border-top-width 80ms linear, border-bottom-width 80ms linear, bottom 80ms linear;
border-left: 4px solid var(--vscode-editorGutter-deletedBackground);
transition: border-top-width 80ms linear, border-bottom-width 80ms linear, bottom 80ms linear, opacity 0.5s;
pointer-events: none;
}

.monaco-editor .dirty-diff-glyph:before {
position: absolute;
content: '';
height: 100%;
width: 0;
left: -2px;
transition: width 80ms linear, left 80ms linear, transform 80ms linear;
}

.monaco-editor .dirty-diff-deleted:before {
background: var(--vscode-editorGutter-deletedBackground);
margin-left: 3px;
height: 0;
bottom: 0;
transition: height 80ms linear;
}

/* Hide glyph decorations when inside the inline diff editor */
.monaco-editor.modified-in-monaco-diff-editor .margin-view-overlays > div > .dirty-diff-glyph {
display: none;
}