diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-07-14 13:45:10 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-07-14 13:45:10 -0700 |
commit | c5102b0997baa81ce544514d6b5b4d5a2eae804f (patch) | |
tree | 667890758eadb0be303e42eb90a494f515dffaf2 /extension | |
parent | b19076ddb6d11acb5ffd54046d9e5cad549c00c1 (diff) | |
download | sncontinue-c5102b0997baa81ce544514d6b5b4d5a2eae804f.tar.gz sncontinue-c5102b0997baa81ce544514d6b5b4d5a2eae804f.tar.bz2 sncontinue-c5102b0997baa81ce544514d6b5b4d5a2eae804f.zip |
insidious client_state vs application_state err
Diffstat (limited to 'extension')
-rw-r--r-- | extension/react-app/src/components/ComboBox.tsx | 9 | ||||
-rw-r--r-- | extension/react-app/src/components/StepContainer.tsx | 9 | ||||
-rw-r--r-- | extension/src/continueIdeClient.ts | 8 | ||||
-rw-r--r-- | extension/src/diffs.ts | 2 | ||||
-rw-r--r-- | extension/src/util/messenger.ts | 2 |
5 files changed, 22 insertions, 8 deletions
diff --git a/extension/react-app/src/components/ComboBox.tsx b/extension/react-app/src/components/ComboBox.tsx index 5d9b5109..754c9445 100644 --- a/extension/react-app/src/components/ComboBox.tsx +++ b/extension/react-app/src/components/ComboBox.tsx @@ -169,6 +169,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { useImperativeHandle(ref, () => downshiftProps, [downshiftProps]); const [metaKeyPressed, setMetaKeyPressed] = useState(false); + const [focused, setFocused] = useState(false); useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (e.key === "Meta") { @@ -298,7 +299,11 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { // setShowContextDropdown(target.value.endsWith("@")); }, + onFocus: (e) => { + setFocused(true); + }, onBlur: (e) => { + setFocused(false); postVscMessage("blurContinueInput", {}); }, onKeyDown: (event) => { @@ -374,7 +379,9 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { </div> {highlightedCodeSections.length === 0 && (downshiftProps.inputValue?.startsWith("/edit") || - (metaKeyPressed && downshiftProps.inputValue?.length > 0)) && ( + (focused && + metaKeyPressed && + downshiftProps.inputValue?.length > 0)) && ( <div className="text-trueGray-400 pr-4 text-xs text-right"> Inserting at cursor </div> diff --git a/extension/react-app/src/components/StepContainer.tsx b/extension/react-app/src/components/StepContainer.tsx index 6fa4ba13..14e9b854 100644 --- a/extension/react-app/src/components/StepContainer.tsx +++ b/extension/react-app/src/components/StepContainer.tsx @@ -253,9 +253,12 @@ function StepContainer(props: StepContainerProps) { )} {props.historyNode.observation?.error ? ( - <pre className="overflow-x-scroll"> - {props.historyNode.observation.error as string} - </pre> + <details> + <summary>View Traceback</summary> + <pre className="overflow-x-scroll"> + {props.historyNode.observation.error as string} + </pre> + </details> ) : ( <StyledMarkdownPreview source={props.historyNode.step.description || ""} diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts index 4c1fdf1e..6dd117d3 100644 --- a/extension/src/continueIdeClient.ts +++ b/extension/src/continueIdeClient.ts @@ -386,8 +386,12 @@ class IdeProtocolClient { contents = editor.document.getText(); } }); - if (!contents) { - contents = fs.readFileSync(filepath, "utf-8"); + if (typeof contents === "undefined") { + if (fs.existsSync(filepath)) { + contents = fs.readFileSync(filepath, "utf-8"); + } else { + contents = ""; + } } return contents; } diff --git a/extension/src/diffs.ts b/extension/src/diffs.ts index 37943de4..d04f9bdb 100644 --- a/extension/src/diffs.ts +++ b/extension/src/diffs.ts @@ -129,7 +129,7 @@ class DiffManager { // Open the diff editor if this is a new diff if (!this.diffs.has(newFilepath)) { // Figure out the first line that is different - const oldContent = fs.readFileSync(originalFilepath).toString("utf-8"); + const oldContent = ideProtocolClient.readFile(originalFilepath); const line = this._findFirstDifferentLine(oldContent, newContent); const diffInfo: DiffInfo = { diff --git a/extension/src/util/messenger.ts b/extension/src/util/messenger.ts index 7fd71ddd..3044898e 100644 --- a/extension/src/util/messenger.ts +++ b/extension/src/util/messenger.ts @@ -15,7 +15,7 @@ export abstract class Messenger { abstract onOpen(callback: () => void): void; abstract onClose(callback: () => void): void; - + abstract onError(callback: () => void): void; abstract sendAndReceive(messageType: string, data: any): Promise<any>; |