Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,14 @@ class InputEditorDecorations extends Disposable {

const viewModel = this.widget.viewModel;
if (!viewModel) {
this.updateAriaPlaceholder(undefined);
return;
}

if (!inputValue) {
const mode = this.widget.input.currentModeObs.get();
const placeholder = mode.argumentHint?.get() ?? mode.description.get() ?? '';
const displayPlaceholder = viewModel.inputPlaceholder || placeholder;

const decoration: IDecorationOptions[] = [
{
Expand All @@ -151,16 +153,19 @@ class InputEditorDecorations extends Disposable {
},
renderOptions: {
after: {
contentText: viewModel.inputPlaceholder || placeholder,
contentText: displayPlaceholder,
color: this.getPlaceholderColor()
}
}
}
];
this.updateAriaPlaceholder(displayPlaceholder || undefined);
this.widget.inputEditor.setDecorationsByType(decorationDescription, placeholderDecorationType, decoration);
return;
}

this.updateAriaPlaceholder(undefined);

const parsedRequest = this.widget.parsedInput.parts;

let placeholderDecoration: IDecorationOptions[] | undefined;
Expand Down Expand Up @@ -295,6 +300,19 @@ class InputEditorDecorations extends Disposable {

this.widget.inputEditor.setDecorationsByType(decorationDescription, variableTextDecorationType, varDecorations);
}

private updateAriaPlaceholder(value: string | undefined): void {
// eslint-disable-next-line no-restricted-syntax
const nativeEditContext = this.widget.inputEditor.getDomNode()?.querySelector<HTMLElement>('.native-edit-context');
if (!nativeEditContext) {
return;
}
if (value && value.trim().length) {
nativeEditContext.setAttribute('aria-placeholder', value);
} else {
nativeEditContext.removeAttribute('aria-placeholder');
}
}
}

class InputEditorSlashCommandMode extends Disposable {
Expand Down
Loading