Skip to content

Commit

Permalink
chore: prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
mikbry committed Feb 29, 2024
1 parent 5a82a06 commit a7fc2ea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion webapp/components/views/Threads/PromptCommandInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function PromptCommandInput({
if (textarea && dropdown) {
const { currentWord, caretStartIndex } = getCurrentWord(textarea);
valueChange(text, caretStartIndex);
const start = text.trim().length -currentWord.length;
const start = text.trim().length - currentWord.length;
if (value && !value.locked && isCommand(currentWord, start)) {
setCommandValue(currentWord);
positionDropdown();
Expand Down
14 changes: 11 additions & 3 deletions webapp/utils/parsers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,23 @@ export function parsePrompt(options: ParsePromptOptions, validator: TokenValidat
const tokens: PromptToken[] = [];
const spans = value.split(/(?<=^| )([@|#|/][\p{L}0-9._-]+)|(\n)/gu);
let index = 0;
const parsedPrompt: ParsedPrompt = { tokens, caretPosition, raw: value, text: '', currentTokenIndex: 0 };
const parsedPrompt: ParsedPrompt = {
tokens,
caretPosition,
raw: value,
text: '',
currentTokenIndex: 0,
};
let previousToken: PromptToken | undefined;
let locked: boolean | undefined;
spans.forEach((span) => {
if (!span) {
return;
}
let text = span || ' ';
const type = locked ? PromptTokenType.Text : getTokenType(text, parsedPrompt.text.trim().length);
const type = locked
? PromptTokenType.Text
: getTokenType(text, parsedPrompt.text.trim().length);
let token: PromptToken = { type, value: text, index };
if (type !== PromptTokenType.Text || previousToken?.type === PromptTokenType.Hashtag) {
[token, previousToken] = validator(token, parsedPrompt, previousToken);
Expand Down Expand Up @@ -135,7 +143,7 @@ export function parsePrompt(options: ParsePromptOptions, validator: TokenValidat
tokens.push(token);
index += text.length;
});
if (locked){
if (locked) {
parsedPrompt.locked = true;
}
return parsedPrompt;
Expand Down
1 change: 0 additions & 1 deletion webapp/utils/parsers/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ const validator = (
}
blockOtherCommands = command?.validate?.();
}

} else if (type === PromptTokenType.Text && _previousToken?.type === PromptTokenType.Hashtag) {
const previousCommand = commandManager.getCommand(_previousToken.value, _previousToken.type);
if (previousCommand && previousCommand.group !== 'parameters-boolean') {
Expand Down

0 comments on commit a7fc2ea

Please sign in to comment.