Archived
fix: restore chat prompt spellcheck
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jmfederico/pi-web": patch
|
||||
---
|
||||
|
||||
Restore spellcheck and autocorrect for prose in the web chat prompt while keeping command-like input protected from autocorrection.
|
||||
@@ -109,6 +109,7 @@ export class PromptEditor extends LitElement {
|
||||
indentUnit.of(" "),
|
||||
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
|
||||
EditorView.lineWrapping,
|
||||
EditorView.contentAttributes.of((view) => inputAssistanceContentAttributes(view.state.sliceDoc(0, view.state.selection.main.head))),
|
||||
placeholder("Message pi... Use / for commands, @ for files"),
|
||||
this.editableCompartment.of(EditorView.editable.of(!this.disabled)),
|
||||
this.readOnlyCompartment.of(EditorState.readOnly.of(this.disabled)),
|
||||
@@ -299,3 +300,22 @@ function emptyFileSuggestions(): FileSuggestion[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
const proseInputAssistanceAttributes: Record<string, string> = {
|
||||
spellcheck: "true",
|
||||
autocorrect: "on",
|
||||
autocapitalize: "sentences",
|
||||
writingsuggestions: "true",
|
||||
};
|
||||
|
||||
const codeLikeInputAssistanceAttributes: Record<string, string> = {
|
||||
spellcheck: "false",
|
||||
autocorrect: "off",
|
||||
autocapitalize: "off",
|
||||
writingsuggestions: "false",
|
||||
};
|
||||
|
||||
function inputAssistanceContentAttributes(draftBeforeCursor: string): Record<string, string> {
|
||||
// CodeMirror is optimized for code and disables these by default, but the chat prompt is usually prose.
|
||||
return inputModeForDraft(draftBeforeCursor).kind === "normal" ? proseInputAssistanceAttributes : codeLikeInputAssistanceAttributes;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user