add keyboard shortcuts to accept/reject

This commit is contained in:
Test
2024-11-21 18:53:33 -08:00
parent 8a4118db1d
commit 5a82374077
5 changed files with 25 additions and 14 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

@@ -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,12 +51,12 @@ 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 && (
{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 =

View File

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