Merge pull request #3032 from continuedev/pe/mfe-followups

feat: more edit UI enhancements
This commit is contained in:
Patrick Erichsen 2024-11-22 10:02:31 -08:00 • committed by GitHub
commit de3f9aff3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 33 additions and 23 deletions

View file

@ -218,10 +218,16 @@ async function processDiff(
} else if (fullPath) {
fullPath = getFullyQualifiedPath(ide, fullPath);
} else {
console.warn(`Unable to resolve filepath: ${newFilepath}`);
const curFile = await ide.getCurrentFile();
fullPath = curFile?.path;
}
if (!fullPath) return;
if (!fullPath) {
console.warn(
`Unable to resolve filepath while attempting to resolve diff: ${newFilepath}`,
);
return;
}
await ide.openFile(fullPath);

View file

@ -2,6 +2,7 @@ import { useContext } from "react";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline";
import { ApplyState } from "core";
import { getMetaKeyLabel } from "../../util";
export interface AcceptRejectAllButtonsProps {
pendingApplyStates: ApplyState[];
@ -37,7 +38,7 @@ export default function AcceptRejectAllButtons({
>
<XMarkIcon className="mr-1 h-4 w-4 text-red-600" />
{hasSinglePendingApplyStates ? (
<span>Reject</span>
<span>Reject ({getMetaKeyLabel()}⇧⌫)</span>
) : (
<>
<span className="sm:hidden">Reject</span>
@ -52,7 +53,7 @@ export default function AcceptRejectAllButtons({
>
<CheckIcon className="mr-1 h-4 w-4 text-green-600" />
{hasSinglePendingApplyStates ? (
<span>Accept</span>
<span>Accept ({getMetaKeyLabel()}⇧⏎)</span>
) : (
<>
<span className="sm:hidden">Accept</span>

View file

@ -29,7 +29,7 @@ export default function AddFileButton() {
<div className="relative">
<Listbox.Button
ref={buttonRef}
className="bg-lightgray/10 border-lightgray flex cursor-pointer items-center justify-between rounded-md border-[0.5px] border-solid px-0 shadow-sm transition-colors"
className="bg-vsc-editor-background border-lightgray/50 flex cursor-pointer items-center justify-between rounded-md border border-solid px-0 shadow-sm transition-colors"
>
<div
className="flex items-center gap-1 px-1.5 hover:brightness-125"
@ -45,17 +45,15 @@ export default function AddFileButton() {
</span>
</div>
<div className="border-lightgray h-4 w-[1px] border-y-0 border-l-0 border-r border-solid" />
<div className="border-lightgray/50 h-4 w-[1px] border-y-0 border-l-0 border-r border-solid" />
<ChevronDownIcon className="text-vsc-foreground h-2.5 w-2.5 cursor-pointer px-1 brightness-75 hover:brightness-125" />
</Listbox.Button>
<Listbox.Options
className={`bg-vsc-input-background border-lightgray absolute right-0 top-full z-50 mt-1 min-w-fit whitespace-nowrap rounded-md border border-solid px-1 py-0 shadow-lg`}
>
<Listbox.Options className="bg-vsc-editor-background border-lightgray/50 absolute right-0 top-full z-50 mt-1 min-w-fit whitespace-nowrap rounded-md border border-solid px-1 py-0 shadow-lg">
<Listbox.Option
value="addAllFiles"
className="text-vsc-foreground hover:bg-lightgray/33 block w-full cursor-pointer px-2 py-1 text-left text-[10px] brightness-75 hover:brightness-125"
className="text-vsc-foreground block w-full cursor-pointer px-2 py-1 text-left text-[10px] brightness-75 hover:brightness-125"
>
Add all open files
</Listbox.Option>

View file

@ -11,16 +11,16 @@ import AddFileButton from "./AddFileButton";
export default function WorkingSet() {
const dispatch = useDispatch();
const ideMessenger = useContext(IdeMessengerContext);
const editModeState = useSelector((state: RootState) => state.editModeState);
const hasCodeToEdit = editModeState.codeToEdit.length > 0;
const codeToEdit = useSelector(
(state: RootState) => state.editModeState.codeToEdit,
);
const title =
editModeState.codeToEdit.length === 0
codeToEdit.length === 0
? "Code to edit"
: editModeState.codeToEdit.length === 1
: codeToEdit.length === 1
? "Code to edit (1 item)"
: `Code to edit (${editModeState.codeToEdit.length} items)`;
: `Code to edit (${codeToEdit.length} items)`;
function onDelete(rif: RangeInFileWithContents) {
dispatch(removeCodeToEdit(rif));
@ -38,7 +38,7 @@ export default function WorkingSet() {
}
}
const codeToEditItems = [...editModeState.codeToEdit]
const codeToEditItems = [...codeToEdit]
.reverse()
.map((code, i) => (
<CodeToEditListItem
@ -51,13 +51,13 @@ export default function WorkingSet() {
return (
<div className="bg-vsc-editor-background border-vsc-input-border mx-1 flex flex-col rounded-t-lg border border-b-0 border-solid p-1">
<div className="text-lightgray flex items-center justify-between gap-1.5 px-1 py-1.5 text-xs">
<div className="text-lightgray flex items-center justify-between gap-1.5 py-1.5 pl-3 pr-2 text-xs">
<span>{title}</span>
<AddFileButton />
</div>
{hasCodeToEdit && (
<ul className="no-scrollbar mb-1.5 mt-1 max-h-[50vh] list-outside list-none space-y-1.5 overflow-y-auto pl-0">
{codeToEdit.length > 0 && (
<ul className="no-scrollbar mb-1.5 mt-1 max-h-[50vh] list-outside list-none overflow-y-auto pl-0">
{codeToEditItems}
</ul>
)}

View file

@ -40,7 +40,10 @@ export default function CodeToEditListItem({
let title = filepath;
if ("range" in code) {
title += ` (${code.range.start.line + 1} - ${code.range.end.line + 1})`;
const start = code.range.start.line + 1;
const end = code.range.end.line + 1;
title +=
start === end ? ` - Inserting at line ${start}` : ` (${start} - ${end})`;
}
const source =
@ -53,7 +56,7 @@ export default function CodeToEditListItem({
return (
<li
className="flex cursor-pointer flex-col"
className="group flex cursor-pointer flex-col"
onClick={() => setShowCodeSnippet((showCodeSnippet) => !showCodeSnippet)}
>
<div
@ -88,7 +91,7 @@ export default function CodeToEditListItem({
{title}
</span>
</div>
<div className="flex gap-1.5">
<div className="invisible flex gap-1.5 group-hover:visible">
<XMarkIcon
onClick={(e) => {
e.stopPropagation();
@ -98,6 +101,7 @@ export default function CodeToEditListItem({
/>
</div>
</div>
{showCodeSnippet && (
<div className="max-h-[25vh] overflow-y-auto px-1 py-2">
<NoPaddingWrapper>

View file

@ -11,6 +11,7 @@ public class Calculator {
return this;
}
public double getResult() {
return result;
}