💄 toggle to show context items
This commit is contained in:
parent
5ccd1dceac
commit
f6a516c09a
4 changed files with 440 additions and 386 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -22,6 +22,8 @@ import {
|
|||
ArrowLeftIcon,
|
||||
ArrowRightIcon,
|
||||
ArrowUpLeftIcon,
|
||||
ChevronDownIcon,
|
||||
ChevronRightIcon,
|
||||
TrashIcon,
|
||||
XMarkIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
|
|
@ -731,6 +733,8 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
|
||||
const [isComposing, setIsComposing] = useState(false);
|
||||
|
||||
const [showContextToggleOn, setShowContextToggleOn] = useState(false);
|
||||
|
||||
const [previewingContextItem, setPreviewingContextItem] = useState<
|
||||
ContextItem | undefined
|
||||
>(undefined);
|
||||
|
|
@ -788,6 +792,26 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
ref={contextItemsDivRef}
|
||||
style={{ backgroundColor: vscBackground }}
|
||||
>
|
||||
{selectedContextItems.length > 0 && (
|
||||
<div
|
||||
className="cursor-pointer"
|
||||
onClick={(e) => {
|
||||
setShowContextToggleOn((prev) => !prev);
|
||||
}}
|
||||
id="toggle-context-div"
|
||||
>
|
||||
{showContextToggleOn ? (
|
||||
<ChevronDownIcon width="14px" height="14px" color={lightGray} />
|
||||
) : (
|
||||
<ChevronRightIcon
|
||||
width="14px"
|
||||
height="14px"
|
||||
color={lightGray}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<HiddenHeaderButtonWithText
|
||||
className={
|
||||
selectedContextItems.length > 0
|
||||
|
|
@ -944,6 +968,25 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
/>
|
||||
</pre>
|
||||
)}
|
||||
{showContextToggleOn && (
|
||||
<div>
|
||||
{selectedContextItems.map((item) => (
|
||||
<>
|
||||
<p className="break-words mx-2 my-1">
|
||||
{item.description.description}
|
||||
</p>
|
||||
<pre className="m-0">
|
||||
<StyledMarkdownPreview
|
||||
source={`\`\`\`${getMarkdownLanguageTagForFile(
|
||||
item.description.description
|
||||
)}\n${item.content}\n\`\`\``}
|
||||
maxHeight={200}
|
||||
/>
|
||||
</pre>
|
||||
</>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<div
|
||||
className="flex px-2 relative"
|
||||
style={{
|
||||
|
|
@ -988,7 +1031,12 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
dispatch(setBottomMessage(undefined));
|
||||
},
|
||||
onBlur: (e) => {
|
||||
if (topRef.current?.contains(e.relatedTarget as Node)) {
|
||||
if (
|
||||
topRef.current?.contains(e.relatedTarget as Node) ||
|
||||
document
|
||||
.getElementById("toggle-context-div")
|
||||
?.contains(e.relatedTarget as Node)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
setInputFocused(false);
|
||||
|
|
|
|||
|
|
@ -308,6 +308,8 @@ class HighlightedCodeContextProvider(ContextProvider):
|
|||
await self.sdk.ide.highlightCode(
|
||||
RangeInFile(
|
||||
filepath=filepath,
|
||||
range=Range.from_shorthand(line_nums[0] - 1, 0, line_nums[1], 0),
|
||||
range=Range.from_shorthand(
|
||||
int(line_nums[0]) - 1, 0, int(line_nums[1]), 0
|
||||
),
|
||||
)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue