Merge pull request #93 from covespace/improve-display

Improve display
This commit is contained in:
Rankin Zheng 2023-05-19 07:55:30 +08:00 committed by GitHub
commit 3c1c0d7704
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,6 +50,7 @@ const chatPanel = () => {
const handlePlusClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setMenuType('contexts');
setMenuOpend(!menuOpend);
inputRef.current.focus();
event.stopPropagation();
};
@ -289,22 +290,27 @@ const chatPanel = () => {
};
const handleKeyDown = (event: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (menuOpend && menuType === 'commands') {
if (event.key === 'ArrowDown') {
const newIndex = currentMenuIndex + 1;
setCurrentMenuIndex(newIndex < commandMenusNode.length ? newIndex : 0);
event.preventDefault();
}
if (event.key === 'ArrowUp') {
const newIndex = currentMenuIndex - 1;
setCurrentMenuIndex(newIndex < 0 ? commandMenusNode.length - 1 : newIndex);
event.preventDefault();
}
if (event.key === 'Enter' && !event.shiftKey) {
const commandNode = commandMenusNode[currentMenuIndex];
setInput(`/${commandNode.props['data-pattern']} `);
if (menuOpend) {
if (event.key === 'Escape') {
setMenuOpend(false);
event.preventDefault();
}
if (menuType === 'commands') {
if (event.key === 'ArrowDown') {
const newIndex = currentMenuIndex + 1;
setCurrentMenuIndex(newIndex < commandMenusNode.length ? newIndex : 0);
event.preventDefault();
}
if (event.key === 'ArrowUp') {
const newIndex = currentMenuIndex - 1;
setCurrentMenuIndex(newIndex < 0 ? commandMenusNode.length - 1 : newIndex);
event.preventDefault();
}
if (event.key === 'Enter' && !event.shiftKey) {
const commandNode = commandMenusNode[currentMenuIndex];
setInput(`/${commandNode.props['data-pattern']} `);
setMenuOpend(false);
event.preventDefault();
}
}
} else {
if (event.key === 'Enter' && !event.shiftKey) {
@ -855,13 +861,20 @@ const chatPanel = () => {
justify="flex-start"
align="center"
direction="row"
wrap="wrap">
<IconMouseRightClick size={14} color={'var(--vscode-menu-foreground)'} style={{ marginLeft: '12px' }} />
wrap="wrap"
sx={{ overflow: 'hidden' }}
>
<IconMouseRightClick
size={14}
color={'var(--vscode-menu-foreground)'}
style={{ marginLeft: '12px' }} />
<Text
c="dimmed"
ta="left"
fz='sm'
m='12px 5px'>
m='12px 5px'
truncate='end'
w={chatContainerRect.width - 60}>
Tips: Select code or file & right click
</Text>
</Flex>