fix: apply code- discard button
This commit is contained in:
@ -8,7 +8,7 @@ interface ApplyButtonProps {
|
||||
activeFileName: string
|
||||
activeFileContent: string
|
||||
editorRef: { current: any }
|
||||
onApply: (mergedCode: string) => void
|
||||
onApply: (mergedCode: string, originalCode: string) => void
|
||||
}
|
||||
|
||||
export default function ApplyButton({
|
||||
@ -48,7 +48,7 @@ export default function ApplyButton({
|
||||
mergedCode += decoder.decode(value, { stream: true })
|
||||
}
|
||||
}
|
||||
onApply(mergedCode.trim())
|
||||
onApply(mergedCode.trim(), activeFileContent)
|
||||
} catch (error) {
|
||||
console.error("Error applying code:", error)
|
||||
toast.error(
|
||||
|
@ -17,7 +17,7 @@ export const createMarkdownComponents = (
|
||||
activeFileName: string,
|
||||
activeFileContent: string,
|
||||
editorRef: any,
|
||||
handleApplyCode: (mergedCode: string) => void,
|
||||
handleApplyCode: (mergedCode: string, originalCode: string) => void,
|
||||
selectFile: (tab: TTab) => void,
|
||||
mergeDecorationsCollection?: monaco.editor.IEditorDecorationsCollection,
|
||||
setMergeDecorationsCollection?: (collection: undefined) => void
|
||||
@ -61,7 +61,7 @@ export const createMarkdownComponents = (
|
||||
mergeDecorationsCollection &&
|
||||
editorRef?.current
|
||||
) {
|
||||
mergeDecorationsCollection.clear()
|
||||
mergeDecorationsCollection?.clear()
|
||||
setMergeDecorationsCollection(undefined)
|
||||
}
|
||||
}}
|
||||
@ -75,14 +75,15 @@ export const createMarkdownComponents = (
|
||||
<div className="w-px bg-input"></div>
|
||||
<Button
|
||||
onClick={() => {
|
||||
if (
|
||||
setMergeDecorationsCollection &&
|
||||
mergeDecorationsCollection &&
|
||||
editorRef?.current
|
||||
) {
|
||||
editorRef.current.getModel()?.setValue(activeFileContent)
|
||||
mergeDecorationsCollection.clear()
|
||||
setMergeDecorationsCollection(undefined)
|
||||
if (editorRef?.current && mergeDecorationsCollection) {
|
||||
const model = editorRef.current.getModel()
|
||||
if (model && (model as any).originalContent) {
|
||||
editorRef.current?.setValue(
|
||||
(model as any).originalContent
|
||||
)
|
||||
mergeDecorationsCollection.clear()
|
||||
setMergeDecorationsCollection?.(undefined)
|
||||
}
|
||||
}
|
||||
}}
|
||||
size="sm"
|
||||
|
@ -57,7 +57,7 @@ export interface AIChatProps {
|
||||
templateType: string
|
||||
templateConfig?: TemplateConfig
|
||||
projectName: string
|
||||
handleApplyCode: (mergedCode: string) => void
|
||||
handleApplyCode: (mergedCode: string, originalCode: string) => void
|
||||
mergeDecorationsCollection?: monaco.editor.IEditorDecorationsCollection
|
||||
setMergeDecorationsCollection?: (collection: undefined) => void
|
||||
selectFile: (tab: TTab) => void
|
||||
@ -110,7 +110,7 @@ export interface MessageProps {
|
||||
) => void
|
||||
setIsContextExpanded: (isExpanded: boolean) => void
|
||||
socket: Socket | null
|
||||
handleApplyCode: (mergedCode: string) => void
|
||||
handleApplyCode: (mergedCode: string, originalCode: string) => void
|
||||
activeFileName: string
|
||||
activeFileContent: string
|
||||
editorRef: any
|
||||
|
Reference in New Issue
Block a user