未验证 提交 168ebd1e 编写于 作者: J João Moreno

fixes #95599

上级 256066f9
......@@ -563,20 +563,57 @@ export class DirtyDiffController extends Disposable implements IEditorContributi
private session: IDisposable = Disposable.None;
private mouseDownInfo: { lineNumber: number } | null = null;
private enabled = false;
private gutterActionDisposables = new DisposableStore();
private stylesheet: HTMLStyleElement;
constructor(
private editor: ICodeEditor,
@IContextKeyService contextKeyService: IContextKeyService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IInstantiationService private readonly instantiationService: IInstantiationService
) {
super();
this.enabled = !contextKeyService.getContextKeyValue('isInDiffEditor');
this.stylesheet = createStyleSheet();
this._register(toDisposable(() => this.stylesheet.remove()));
if (this.enabled) {
this.isDirtyDiffVisible = isDirtyDiffVisible.bindTo(contextKeyService);
this._register(editor.onMouseDown(e => this.onEditorMouseDown(e)));
this._register(editor.onMouseUp(e => this.onEditorMouseUp(e)));
this._register(editor.onDidChangeModel(() => this.close()));
const onDidChangeGutterAction = Event.filter(configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('scm.diffDecorationsGutterAction'));
this._register(onDidChangeGutterAction(this.onDidChangeGutterAction, this));
this.onDidChangeGutterAction();
}
}
private onDidChangeGutterAction(): void {
const gutterAction = this.configurationService.getValue<'diff' | 'none'>('scm.diffDecorationsGutterAction');
this.gutterActionDisposables.dispose();
this.gutterActionDisposables = new DisposableStore();
if (gutterAction === 'diff') {
this.gutterActionDisposables.add(this.editor.onMouseDown(e => this.onEditorMouseDown(e)));
this.gutterActionDisposables.add(this.editor.onMouseUp(e => this.onEditorMouseUp(e)));
this.stylesheet.textContent = `
.monaco-editor .dirty-diff-glyph {
cursor: pointer;
}
.monaco-editor .margin-view-overlays .dirty-diff-glyph:hover::before {
width: 9px;
left: -6px;
}
.monaco-editor .margin-view-overlays .dirty-diff-deleted:hover::after {
bottom: 0;
border-top-width: 0;
border-bottom-width: 0;
}
`;
} else {
this.stylesheet.textContent = ``;
}
}
......@@ -798,6 +835,11 @@ export class DirtyDiffController extends Disposable implements IEditorContributi
return model.changes;
}
dispose(): void {
this.gutterActionDisposables.dispose();
super.dispose();
}
}
export const editorGutterModifiedBackground = registerColor('editorGutter.modifiedBackground', {
......
......@@ -5,7 +5,6 @@
.monaco-editor .dirty-diff-glyph {
margin-left: 5px;
cursor: pointer;
z-index: 5;
}
......@@ -39,20 +38,6 @@
transition: height 80ms linear;
}
.monaco-editor .margin-view-overlays .dirty-diff-glyph:hover::before {
position: absolute;
content: '';
height: 100%;
width: 9px;
left: -6px;
}
.monaco-editor .margin-view-overlays .dirty-diff-deleted:hover::after {
bottom: 0;
border-top-width: 0;
border-bottom-width: 0;
}
/* 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;
......
......@@ -138,6 +138,16 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
description: localize('scm.diffDecorationsGutterVisibility', "Controls the visibility of the Source Control diff decorator in the gutter."),
default: 'always'
},
'scm.diffDecorationsGutterAction': {
type: 'string',
enum: ['diff', 'none'],
enumDescriptions: [
localize('scm.diffDecorationsGutterAction.diff', "Show the inline diff peek view on click."),
localize('scm.diffDecorationsGutterAction.none', "Do nothing.")
],
description: localize('scm.diffDecorationsGutterAction', "Controls the behavior of Source Control diff gutter decorations."),
default: 'diff'
},
'scm.alwaysShowActions': {
type: 'boolean',
description: localize('alwaysShowActions', "Controls whether inline actions are always visible in the Source Control view."),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册