Skip to content

Commit b128796

Browse files
authored
Merge pull request microsoft#205514 from microsoft/joh/awful-quelea
Show accessible diff viewer in line chat widget
2 parents 735d80e + 2819e44 commit b128796

File tree

6 files changed

+162
-31
lines changed

6 files changed

+162
-31
lines changed

src/vs/editor/browser/widget/diffEditor/components/accessibleDiffViewer.css

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,66 +3,70 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
.monaco-diff-editor .diff-review-line-number {
7-
text-align: right;
8-
display: inline-block;
9-
color: var(--vscode-editorLineNumber-foreground);
6+
.monaco-component.diff-review {
7+
user-select: none;
8+
-webkit-user-select: none;
9+
z-index: 99;
1010
}
1111

1212
.monaco-diff-editor .diff-review {
1313
position: absolute;
14-
user-select: none;
15-
-webkit-user-select: none;
16-
z-index: 99;
14+
15+
}
16+
17+
.monaco-component.diff-review .diff-review-line-number {
18+
text-align: right;
19+
display: inline-block;
20+
color: var(--vscode-editorLineNumber-foreground);
1721
}
1822

19-
.monaco-diff-editor .diff-review-summary {
23+
.monaco-component.diff-review .diff-review-summary {
2024
padding-left: 10px;
2125
}
2226

23-
.monaco-diff-editor .diff-review-shadow {
27+
.monaco-component.diff-review .diff-review-shadow {
2428
position: absolute;
2529
box-shadow: var(--vscode-scrollbar-shadow) 0 -6px 6px -6px inset;
2630
}
2731

28-
.monaco-diff-editor .diff-review-row {
32+
.monaco-component.diff-review .diff-review-row {
2933
white-space: pre;
3034
}
3135

32-
.monaco-diff-editor .diff-review-table {
36+
.monaco-component.diff-review .diff-review-table {
3337
display: table;
3438
min-width: 100%;
3539
}
3640

37-
.monaco-diff-editor .diff-review-row {
41+
.monaco-component.diff-review .diff-review-row {
3842
display: table-row;
3943
width: 100%;
4044
}
4145

42-
.monaco-diff-editor .diff-review-spacer {
46+
.monaco-component.diff-review .diff-review-spacer {
4347
display: inline-block;
4448
width: 10px;
4549
vertical-align: middle;
4650
}
4751

48-
.monaco-diff-editor .diff-review-spacer > .codicon {
52+
.monaco-component.diff-review .diff-review-spacer > .codicon {
4953
font-size: 9px !important;
5054
}
5155

52-
.monaco-diff-editor .diff-review-actions {
56+
.monaco-component.diff-review .diff-review-actions {
5357
display: inline-block;
5458
position: absolute;
5559
right: 10px;
5660
top: 2px;
5761
z-index: 100;
5862
}
5963

60-
.monaco-diff-editor .diff-review-actions .action-label {
64+
.monaco-component.diff-review .diff-review-actions .action-label {
6165
width: 16px;
6266
height: 16px;
6367
margin: 2px 0;
6468
}
6569

66-
.monaco-diff-editor .revertButton {
70+
.monaco-component.diff-review .revertButton {
6771
cursor: pointer;
6872
}

src/vs/editor/browser/widget/diffEditor/components/accessibleDiffViewer.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ class View extends Disposable {
354354
super();
355355

356356
this.domNode = this._element;
357-
this.domNode.className = 'diff-review monaco-editor-background';
357+
this.domNode.className = 'monaco-component diff-review monaco-editor-background';
358358

359359
const actionBarContainer = document.createElement('div');
360360
actionBarContainer.className = 'diff-review-actions';
@@ -381,6 +381,12 @@ class View extends Disposable {
381381
this._scrollbar = this._register(new DomScrollableElement(this._content, {}));
382382
reset(this.domNode, this._scrollbar.getDomNode(), actionBarContainer);
383383

384+
this._register(autorun(r => {
385+
this._height.read(r);
386+
this._width.read(r);
387+
this._scrollbar.scanDomNode();
388+
}));
389+
384390
this._register(toDisposable(() => { reset(this.domNode); }));
385391

386392
this._register(applyStyle(this.domNode, { width: this._width, height: this._height }));

src/vs/workbench/contrib/inlineChat/browser/inlineChat.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@
307307
padding-top: 6px;
308308
}
309309

310+
.monaco-editor .inline-chat .diff-review.hidden,
310311
.monaco-editor .inline-chat .previewDiff.hidden,
311312
.monaco-editor .inline-chat .previewCreate.hidden,
312313
.monaco-editor .inline-chat .previewCreateTitle.hidden {

src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import { ProviderResult, TextEdit } from 'vs/editor/common/languages';
2727
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorker';
2828
import { InlineCompletionsController } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionsController';
2929
import { localize } from 'vs/nls';
30-
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
3130
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
3231
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
3332
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
@@ -145,7 +144,6 @@ export class InlineChatController implements IEditorContribution {
145144
@IConfigurationService private readonly _configurationService: IConfigurationService,
146145
@IDialogService private readonly _dialogService: IDialogService,
147146
@IContextKeyService contextKeyService: IContextKeyService,
148-
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,
149147
@IChatAccessibilityService private readonly _chatAccessibilityService: IChatAccessibilityService,
150148
@IChatAgentService private readonly _chatAgentService: IChatAgentService,
151149
@IBulkEditService private readonly _bulkEditService: IBulkEditService,
@@ -235,13 +233,7 @@ export class InlineChatController implements IEditorContribution {
235233
}
236234

237235
private _getMode(): EditMode {
238-
const editMode = this._configurationService.inspect<EditMode>(InlineChatConfigKeys.Mode);
239-
let editModeValue = editMode.value;
240-
if (this._accessibilityService.isScreenReaderOptimized() && editModeValue === editMode.defaultValue) {
241-
// By default, use preview mode for screen reader users
242-
editModeValue = EditMode.Preview;
243-
}
244-
return editModeValue!;
236+
return this._configurationService.getValue<EditMode>(InlineChatConfigKeys.Mode);
245237
}
246238

247239
getWidgetPosition(): Position | undefined {

src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { HunkState } from './inlineChatSession';
3636
import { assertType } from 'vs/base/common/types';
3737
import { IModelService } from 'vs/editor/common/services/model';
3838
import { performAsyncTextEdit, asProgressiveEdit } from './utils';
39+
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
3940

4041
export interface IEditObserver {
4142
start(): void;
@@ -404,6 +405,8 @@ type HunkDisplayData = {
404405
toggleDiff?: () => any;
405406
remove(): void;
406407
move: (next: boolean) => void;
408+
409+
hunk: HunkInformation;
407410
};
408411

409412

@@ -441,6 +444,7 @@ export class LiveStrategy extends EditModeStrategy {
441444
zone: InlineChatZoneWidget,
442445
@IContextKeyService contextKeyService: IContextKeyService,
443446
@IEditorWorkerService protected readonly _editorWorkerService: IEditorWorkerService,
447+
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,
444448
@IInstantiationService protected readonly _instaService: IInstantiationService,
445449
) {
446450
super(session, editor, zone);
@@ -652,6 +656,7 @@ export class LiveStrategy extends EditModeStrategy {
652656
: zoneLineNumber - hunkRanges[0].endLineNumber;
653657

654658
data = {
659+
hunk: hunkData,
655660
decorationIds,
656661
viewZoneId: '',
657662
viewZone: viewZoneData,
@@ -661,7 +666,7 @@ export class LiveStrategy extends EditModeStrategy {
661666
discardHunk,
662667
toggleDiff: !hunkData.isInsertion() ? toggleDiff : undefined,
663668
remove,
664-
move
669+
move,
665670
};
666671

667672
this._hunkDisplayData.set(hunkData, data);
@@ -700,6 +705,10 @@ export class LiveStrategy extends EditModeStrategy {
700705
const remainingHunks = this._session.hunkData.pending;
701706
this._updateSummaryMessage(remainingHunks);
702707

708+
if (this._accessibilityService.isScreenReaderOptimized()) {
709+
this._zone.widget.showAccessibleHunk(this._session, widgetData.hunk);
710+
}
711+
703712
this._ctxCurrentChangeHasDiff.set(Boolean(widgetData.toggleDiff));
704713
this.toggleDiff = widgetData.toggleDiff;
705714
this.acceptHunk = async () => widgetData!.acceptHunk();

0 commit comments

Comments
 (0)