@@ -45,10 +45,10 @@ def rerun(self, result):
45
45
46
46
47
47
class GitAddSelectedHunkCommand (GitTextCommand ):
48
- def run (self , edit ):
49
- self .run_command (['git' , 'diff' , '--no-color' , '-U1' , self .get_file_name ()], self .cull_diff )
48
+ def run (self , edit , edit_patch = False ):
49
+ self .run_command (['git' , 'diff' , '--no-color' , '-U1' , self .get_file_name ()], lambda result : self .cull_diff ( result , edit_patch ) )
50
50
51
- def cull_diff (self , result ):
51
+ def cull_diff (self , result , edit_patch = False ):
52
52
selection = []
53
53
for sel in self .view .sel ():
54
54
selection .append ({
@@ -85,10 +85,22 @@ def cull_diff(self, result):
85
85
selection_is_hunky = True
86
86
87
87
if selection_is_hunky :
88
- self .run_command (['git' , 'apply' , '--cached' ], stdin = diffs )
88
+ if edit_patch : # open an input panel to modify the patch
89
+ patch_view = self .get_window ().show_input_panel (
90
+ "Message" , diffs ,
91
+ lambda edited_patch : self .on_input (edited_patch ), None , None
92
+ )
93
+ s = sublime .load_settings ("Git.sublime-settings" )
94
+ syntax = s .get ("diff_syntax" , "Packages/Diff/Diff.tmLanguage" )
95
+ patch_view .set_syntax_file (syntax )
96
+ patch_view .settings ().set ('word_wrap' , False )
97
+ else :
98
+ self .on_input (diffs )
89
99
else :
90
100
sublime .status_message ("No selected hunk" )
91
101
102
+ def on_input (self , patch ):
103
+ self .run_command (['git' , 'apply' , '--cached' ], stdin = patch )
92
104
93
105
# Also, sometimes we want to undo adds
94
106
0 commit comments