mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2026-04-22 02:54:26 +08:00
Merge fc6ddce88c into 377480b448
This commit is contained in:
@@ -995,6 +995,8 @@ function _Chat() {
|
||||
const fontSize = config.fontSize;
|
||||
const fontFamily = config.fontFamily;
|
||||
|
||||
const slashOffsetRef = useRef(0);
|
||||
|
||||
const [showExport, setShowExport] = useState(false);
|
||||
|
||||
const inputRef = useRef<HTMLTextAreaElement>(null);
|
||||
@@ -1093,10 +1095,13 @@ function _Chat() {
|
||||
setPromptHints([]);
|
||||
} else if (text.match(ChatCommandPrefix)) {
|
||||
setPromptHints(chatCommands.search(text));
|
||||
} else if (!config.disablePromptHint && n < SEARCH_TEXT_LIMIT) {
|
||||
} else if (
|
||||
!config.disablePromptHint &&
|
||||
text.length < slashOffsetRef.current + SEARCH_TEXT_LIMIT
|
||||
) {
|
||||
// check if need to trigger auto completion
|
||||
if (text.startsWith("/")) {
|
||||
let searchText = text.slice(1);
|
||||
if (text.slice(slashOffsetRef.current).startsWith("/")) {
|
||||
let searchText = text.slice(slashOffsetRef.current + 1);
|
||||
onSearch(searchText);
|
||||
}
|
||||
}
|
||||
@@ -1134,7 +1139,7 @@ function _Chat() {
|
||||
setUserInput("");
|
||||
} else {
|
||||
// or fill the prompt
|
||||
setUserInput(prompt.content);
|
||||
setUserInput(prompt.content + userInput.slice(0, slashOffsetRef.current));
|
||||
}
|
||||
inputRef.current?.focus();
|
||||
}, 30);
|
||||
@@ -1185,6 +1190,8 @@ function _Chat() {
|
||||
setUserInput(chatStore.lastInput ?? "");
|
||||
e.preventDefault();
|
||||
return;
|
||||
} else if (e.key === "/") {
|
||||
slashOffsetRef.current = userInput.length;
|
||||
}
|
||||
if (shouldSubmit(e) && promptHints.length === 0) {
|
||||
doSubmit(userInput);
|
||||
|
||||
Reference in New Issue
Block a user