Skip to content

Commit 2cd3b0e

Browse files
committed
Prioritize Intelligent Update mode when applying file changes if conflict markers are detected in the content
1 parent cd9df70 commit 2cd3b0e

2 files changed

Lines changed: 33 additions & 7 deletions

File tree

‎packages/vscode/src/commands/apply-chat-response-command/response-processor.ts‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ import { handle_fast_replace } from './handlers/fast-replace-handler'
1818
import { PanelProvider } from '@/views/panel/backend/panel-provider'
1919
import { FileInPreview } from '@shared/types/file-in-preview'
2020
import { update_undo_button_state } from './utils/state-manager'
21-
import { check_if_all_files_new } from './utils/file-checks'
21+
import {
22+
check_if_all_files_new,
23+
check_for_conflict_markers
24+
} from './utils/file-checks'
2225

2326
export type PreviewData = {
2427
original_states: OriginalFileState[]
@@ -457,14 +460,23 @@ export const process_chat_response = async (
457460
) {
458461
has_truncated_fragments = check_for_truncated_fragments(files)
459462
}
463+
const has_conflict_markers = check_for_conflict_markers(files)
460464

461-
if (has_truncated_fragments) {
465+
if (has_truncated_fragments || has_conflict_markers) {
462466
selected_mode_label = 'Intelligent update'
463-
Logger.info({
464-
function_name: 'process_chat_response',
465-
message:
466-
'Auto-selecting intelligent update mode due to detected truncated fragments'
467-
})
467+
if (has_conflict_markers) {
468+
Logger.info({
469+
function_name: 'process_chat_response',
470+
message:
471+
'Auto-selecting intelligent update mode due to detected conflict markers'
472+
})
473+
} else {
474+
Logger.info({
475+
function_name: 'process_chat_response',
476+
message:
477+
'Auto-selecting intelligent update mode due to detected truncated fragments'
478+
})
479+
}
468480
} else {
469481
selected_mode_label = 'Fast replace'
470482
Logger.info({

‎packages/vscode/src/commands/apply-chat-response-command/utils/file-checks.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,17 @@ export const check_if_all_files_new = async (
2727

2828
return true
2929
}
30+
31+
export const check_for_conflict_markers = (files: FileItem[]): boolean => {
32+
for (const file of files) {
33+
const content = file.content
34+
if (
35+
content.includes('<<<<<<<') &&
36+
content.includes('=======') &&
37+
content.includes('>>>>>>>')
38+
) {
39+
return true
40+
}
41+
}
42+
return false
43+
}

0 commit comments

Comments
 (0)