Skip to content

Commit 3285fcb

Browse files
committed
Refactor parse_response calls across the codebase to consistently use the object parameter format { response: string, is_single_root_folder_workspace: boolean }
1 parent bbc0ef8 commit 3285fcb

6 files changed

Lines changed: 144 additions & 52 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,10 @@ export const apply_chat_response_command = (
442442
const is_single_root_folder_workspace =
443443
vscode.workspace.workspaceFolders?.length == 1
444444

445-
let clipboard_content = parse_response(
446-
chat_response,
445+
let clipboard_content = parse_response({
446+
response: chat_response,
447447
is_single_root_folder_workspace
448-
)
448+
})
449449

450450
if (
451451
clipboard_content.type == 'code-completion' &&

‎packages/vscode/src/commands/apply-chat-response-command/utils/clipboard-parser/clipboard-parser.spec.ts‎

Lines changed: 112 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,10 @@ describe('clipboard-parser', () => {
428428
'diff-direct-variant-a',
429429
'diff-direct-variant-a.txt'
430430
)
431-
const result = parse_response(text, true)
431+
const result = parse_response({
432+
response: text,
433+
is_single_root_folder_workspace: true
434+
})
432435

433436
expect(result.type).toBe('patches')
434437
expect(result.patches).toHaveLength(1)
@@ -440,7 +443,10 @@ describe('clipboard-parser', () => {
440443

441444
it('should parse code-completion format', () => {
442445
const text = load_test_case_file('code-completion', 'code-completion.txt')
443-
const result = parse_response(text, true)
446+
const result = parse_response({
447+
response: text,
448+
is_single_root_folder_workspace: true
449+
})
444450

445451
expect(result.type).toBe('code-completion')
446452
expect(result.code_completion).toBeDefined()
@@ -459,7 +465,10 @@ describe('clipboard-parser', () => {
459465
'diff-direct-variant-b',
460466
'diff-direct-variant-b.txt'
461467
)
462-
const result = parse_response(text, true)
468+
const result = parse_response({
469+
response: text,
470+
is_single_root_folder_workspace: true
471+
})
463472

464473
expect(result.type).toBe('patches')
465474
expect(result.patches).toHaveLength(1)
@@ -474,7 +483,10 @@ describe('clipboard-parser', () => {
474483
'diff-direct-variant-c',
475484
'diff-direct-variant-c.txt'
476485
)
477-
const result = parse_response(text, true)
486+
const result = parse_response({
487+
response: text,
488+
is_single_root_folder_workspace: true
489+
})
478490

479491
expect(result.type).toBe('patches')
480492
expect(result.patches).toHaveLength(1)
@@ -489,7 +501,10 @@ describe('clipboard-parser', () => {
489501
'diff-direct-variant-d',
490502
'diff-direct-variant-d.txt'
491503
)
492-
const result = parse_response(text, true)
504+
const result = parse_response({
505+
response: text,
506+
is_single_root_folder_workspace: true
507+
})
493508

494509
expect(result.type).toBe('patches')
495510
expect(result.patches).toHaveLength(1)
@@ -504,7 +519,10 @@ describe('clipboard-parser', () => {
504519
'diff-direct-variant-e',
505520
'diff-direct-variant-e.txt'
506521
)
507-
const result = parse_response(text, true)
522+
const result = parse_response({
523+
response: text,
524+
is_single_root_folder_workspace: true
525+
})
508526

509527
expect(result.type).toBe('patches')
510528
expect(result.patches).toHaveLength(1)
@@ -519,7 +537,10 @@ describe('clipboard-parser', () => {
519537
'diff-direct-variant-f',
520538
'diff-direct-variant-f.txt'
521539
)
522-
const result = parse_response(text, true)
540+
const result = parse_response({
541+
response: text,
542+
is_single_root_folder_workspace: true
543+
})
523544

524545
expect(result.type).toBe('patches')
525546
expect(result.patches).toHaveLength(1)
@@ -534,7 +555,10 @@ describe('clipboard-parser', () => {
534555
'diff-direct-variant-g',
535556
'diff-direct-variant-g.txt'
536557
)
537-
const result = parse_response(text, true)
558+
const result = parse_response({
559+
response: text,
560+
is_single_root_folder_workspace: true
561+
})
538562

539563
expect(result.type).toBe('patches')
540564
expect(result.patches).toHaveLength(1)
@@ -546,7 +570,10 @@ describe('clipboard-parser', () => {
546570

547571
it('should parse direct diff format without a/ b/ prefixes', () => {
548572
const text = load_test_case_file('diff-no-prefix', 'diff-no-prefix.txt')
549-
const result = parse_response(text, true)
573+
const result = parse_response({
574+
response: text,
575+
is_single_root_folder_workspace: true
576+
})
550577

551578
expect(result.type).toBe('patches')
552579
expect(result.patches).toHaveLength(1)
@@ -561,7 +588,10 @@ describe('clipboard-parser', () => {
561588
'diff-direct-variant-deletion',
562589
'diff-direct-variant-deletion.txt'
563590
)
564-
const result = parse_response(text, true)
591+
const result = parse_response({
592+
response: text,
593+
is_single_root_folder_workspace: true
594+
})
565595

566596
expect(result.type).toBe('patches')
567597
expect(result.patches).toHaveLength(1)
@@ -573,7 +603,10 @@ describe('clipboard-parser', () => {
573603

574604
it('should parse direct diff format for file rename', () => {
575605
const text = load_test_case_file('diff-rename', 'diff-rename.txt')
576-
const result = parse_response(text, true)
606+
const result = parse_response({
607+
response: text,
608+
is_single_root_folder_workspace: true
609+
})
577610

578611
expect(result.type).toBe('patches')
579612
expect(result.patches).toHaveLength(1)
@@ -589,7 +622,10 @@ describe('clipboard-parser', () => {
589622
'diff-multiple-files-variant-a',
590623
'diff-multiple-files-variant-a.txt'
591624
)
592-
const result = parse_response(text, true)
625+
const result = parse_response({
626+
response: text,
627+
is_single_root_folder_workspace: true
628+
})
593629

594630
expect(result.type).toBe('patches')
595631
expect(result.patches).toHaveLength(2)
@@ -610,7 +646,10 @@ describe('clipboard-parser', () => {
610646
'diff-multiple-files-variant-b',
611647
'diff-multiple-files-variant-b.txt'
612648
)
613-
const result = parse_response(text, true)
649+
const result = parse_response({
650+
response: text,
651+
is_single_root_folder_workspace: true
652+
})
614653

615654
expect(result.type).toBe('patches')
616655
expect(result.patches).toHaveLength(2)
@@ -631,7 +670,10 @@ describe('clipboard-parser', () => {
631670
'diff-multiple-files-variant-c',
632671
'diff-multiple-files-variant-c.txt'
633672
)
634-
const result = parse_response(text, true)
673+
const result = parse_response({
674+
response: text,
675+
is_single_root_folder_workspace: true
676+
})
635677

636678
expect(result.type).toBe('patches')
637679
expect(result.patches).toHaveLength(2)
@@ -652,7 +694,10 @@ describe('clipboard-parser', () => {
652694
'diff-multiple-files-variant-d',
653695
'diff-multiple-files-variant-d.txt'
654696
)
655-
const result = parse_response(text, true)
697+
const result = parse_response({
698+
response: text,
699+
is_single_root_folder_workspace: true
700+
})
656701

657702
expect(result.type).toBe('patches')
658703
expect(result.patches).toHaveLength(2)
@@ -673,7 +718,10 @@ describe('clipboard-parser', () => {
673718
'diff-multiple-files-variant-e',
674719
'diff-multiple-files-variant-e.txt'
675720
)
676-
const result = parse_response(text, true)
721+
const result = parse_response({
722+
response: text,
723+
is_single_root_folder_workspace: true
724+
})
677725

678726
expect(result.type).toBe('patches')
679727
expect(result.patches).toHaveLength(2)
@@ -694,7 +742,10 @@ describe('clipboard-parser', () => {
694742
'diff-multiple-files-variant-f',
695743
'diff-multiple-files-variant-f.txt'
696744
)
697-
const result = parse_response(text, true)
745+
const result = parse_response({
746+
response: text,
747+
is_single_root_folder_workspace: true
748+
})
698749

699750
expect(result.type).toBe('patches')
700751
expect(result.patches).toHaveLength(2)
@@ -715,7 +766,10 @@ describe('clipboard-parser', () => {
715766
'diff-multiple-files-variant-g',
716767
'diff-multiple-files-variant-g.txt'
717768
)
718-
const result = parse_response(text, true)
769+
const result = parse_response({
770+
response: text,
771+
is_single_root_folder_workspace: true
772+
})
719773

720774
expect(result.type).toBe('patches')
721775
expect(result.patches).toHaveLength(2)
@@ -736,7 +790,10 @@ describe('clipboard-parser', () => {
736790
'diff-multiple-files-variant-h',
737791
'diff-multiple-files-variant-h.txt'
738792
)
739-
const result = parse_response(text, true)
793+
const result = parse_response({
794+
response: text,
795+
is_single_root_folder_workspace: true
796+
})
740797

741798
expect(result.type).toBe('patches')
742799
expect(result.patches).toHaveLength(2)
@@ -757,7 +814,10 @@ describe('clipboard-parser', () => {
757814
'diff-multiple-files-variant-i',
758815
'diff-multiple-files-variant-i.txt'
759816
)
760-
const result = parse_response(text, true)
817+
const result = parse_response({
818+
response: text,
819+
is_single_root_folder_workspace: true
820+
})
761821

762822
expect(result.type).toBe('patches')
763823
expect(result.patches).toHaveLength(2)
@@ -778,7 +838,10 @@ describe('clipboard-parser', () => {
778838
'diff-multiple-files-variant-j',
779839
'diff-multiple-files-variant-j.txt'
780840
)
781-
const result = parse_response(text, true)
841+
const result = parse_response({
842+
response: text,
843+
is_single_root_folder_workspace: true
844+
})
782845

783846
expect(result.type).toBe('patches')
784847
expect(result.patches).toHaveLength(2)
@@ -799,7 +862,10 @@ describe('clipboard-parser', () => {
799862
'diff-multiple-files-variant-k',
800863
'diff-multiple-files-variant-k.txt'
801864
)
802-
const result = parse_response(text, true)
865+
const result = parse_response({
866+
response: text,
867+
is_single_root_folder_workspace: true
868+
})
803869

804870
expect(result.type).toBe('patches')
805871
expect(result.patches).toHaveLength(2)
@@ -820,7 +886,10 @@ describe('clipboard-parser', () => {
820886
'diff-multiple-files-variant-l',
821887
'diff-multiple-files-variant-l.txt'
822888
)
823-
const result = parse_response(text, true)
889+
const result = parse_response({
890+
response: text,
891+
is_single_root_folder_workspace: true
892+
})
824893

825894
expect(result.type).toBe('patches')
826895
expect(result.patches).toHaveLength(2)
@@ -841,7 +910,10 @@ describe('clipboard-parser', () => {
841910
'diff-multiple-files-variant-m',
842911
'diff-multiple-files-variant-m.txt'
843912
)
844-
const result = parse_response(text, true)
913+
const result = parse_response({
914+
response: text,
915+
is_single_root_folder_workspace: true
916+
})
845917

846918
expect(result.type).toBe('patches')
847919
expect(result.patches).toHaveLength(2)
@@ -862,7 +934,10 @@ describe('clipboard-parser', () => {
862934
'diff-multiple-files-variant-n',
863935
'diff-multiple-files-variant-n.txt'
864936
)
865-
const result = parse_response(text, true)
937+
const result = parse_response({
938+
response: text,
939+
is_single_root_folder_workspace: true
940+
})
866941

867942
expect(result.type).toBe('patches')
868943
expect(result.patches).toHaveLength(2)
@@ -883,7 +958,10 @@ describe('clipboard-parser', () => {
883958
'diff-inner-backticks',
884959
'diff-inner-backticks.txt'
885960
)
886-
const result = parse_response(text, true)
961+
const result = parse_response({
962+
response: text,
963+
is_single_root_folder_workspace: true
964+
})
887965

888966
expect(result.type).toBe('patches')
889967
expect(result.patches).toHaveLength(1)
@@ -898,7 +976,10 @@ describe('clipboard-parser', () => {
898976
'diff-inner-triple-backticks',
899977
'diff-inner-triple-backticks.txt'
900978
)
901-
const result = parse_response(text, true)
979+
const result = parse_response({
980+
response: text,
981+
is_single_root_folder_workspace: true
982+
})
902983

903984
expect(result.type).toBe('patches')
904985
expect(result.patches).toHaveLength(1)
@@ -914,7 +995,10 @@ describe('clipboard-parser', () => {
914995
'diff-markdown-missing-ending',
915996
'diff-markdown-missing-ending.txt'
916997
)
917-
const result = parse_response(text, true)
998+
const result = parse_response({
999+
response: text,
1000+
is_single_root_folder_workspace: true
1001+
})
9181002

9191003
expect(result.type).toBe('patches')
9201004
expect(result.patches).toHaveLength(1)

0 commit comments

Comments
 (0)