@@ -46,9 +46,13 @@ impl Component for TagCommitPopup {
46
46
if self . is_visible ( ) || force_all {
47
47
self . input . commands ( out, force_all) ;
48
48
49
+ let is_annotation_mode =
50
+ matches ! ( self . mode, Mode :: Annotation { .. } ) ;
51
+
49
52
out. push ( CommandInfo :: new (
50
53
strings:: commands:: tag_commit_confirm_msg (
51
54
& self . key_config ,
55
+ is_annotation_mode,
52
56
) ,
53
57
self . is_valid_tag ( ) ,
54
58
true ,
@@ -66,37 +70,34 @@ impl Component for TagCommitPopup {
66
70
67
71
fn event ( & mut self , ev : & Event ) -> Result < EventState > {
68
72
if self . is_visible ( ) {
69
- if self . input . event ( ev) ?. is_consumed ( ) {
70
- return Ok ( EventState :: Consumed ) ;
71
- }
72
-
73
73
if let Event :: Key ( e) = ev {
74
- if key_match ( e, self . key_config . keys . enter )
74
+ let is_annotation_mode =
75
+ matches ! ( self . mode, Mode :: Annotation { .. } ) ;
76
+
77
+ if !is_annotation_mode
78
+ && key_match ( e, self . key_config . keys . enter )
75
79
&& self . is_valid_tag ( )
76
80
{
77
81
try_or_popup ! ( self , "tag error:" , self . tag( ) ) ;
82
+ return Ok ( EventState :: Consumed ) ;
83
+ }
84
+ if is_annotation_mode
85
+ && key_match ( e, self . key_config . keys . commit )
86
+ {
87
+ try_or_popup ! ( self , "tag error:" , self . tag( ) ) ;
88
+ return Ok ( EventState :: Consumed ) ;
78
89
} else if key_match (
79
90
e,
80
91
self . key_config . keys . tag_annotate ,
81
92
) && self . is_valid_tag ( )
82
93
{
83
- let tag_name: String =
84
- self . input . get_text ( ) . into ( ) ;
85
-
86
- self . input . clear ( ) ;
87
- self . input . set_title (
88
- strings:: tag_popup_annotation_title (
89
- & tag_name,
90
- ) ,
91
- ) ;
92
- self . input . set_default_msg (
93
- strings:: tag_popup_annotation_msg ( ) ,
94
- ) ;
95
- self . mode = Mode :: Annotation { tag_name } ;
94
+ self . start_annotate_mode ( ) ;
95
+ return Ok ( EventState :: Consumed ) ;
96
96
}
97
-
98
- return Ok ( EventState :: Consumed ) ;
99
97
}
98
+
99
+ self . input . event ( ev) ?;
100
+ return Ok ( EventState :: Consumed ) ;
100
101
}
101
102
Ok ( EventState :: NotConsumed )
102
103
}
@@ -111,6 +112,7 @@ impl Component for TagCommitPopup {
111
112
112
113
fn show ( & mut self ) -> Result < ( ) > {
113
114
self . mode = Mode :: Name ;
115
+ self . input . set_input_type ( InputType :: Singleline ) ;
114
116
self . input . set_title ( strings:: tag_popup_name_title ( ) ) ;
115
117
self . input . set_default_msg ( strings:: tag_popup_name_msg ( ) ) ;
116
118
self . input . show ( ) ?;
@@ -166,6 +168,7 @@ impl TagCommitPopup {
166
168
. flatten ( )
167
169
. and_then ( |val| val. parse :: < bool > ( ) . ok ( ) )
168
170
. unwrap_or_default ( ) ;
171
+
169
172
anyhow:: ensure!( !gpgsign, "config tag.gpgsign=true detected.\n gpg signing not supported.\n deactivate in your repo/gitconfig to be able to tag without signing." ) ;
170
173
171
174
let ( tag_name, tag_annotation) = self . tag_info ( ) ;
@@ -201,4 +204,17 @@ impl TagCommitPopup {
201
204
202
205
Ok ( ( ) )
203
206
}
207
+
208
+ fn start_annotate_mode ( & mut self ) {
209
+ let tag_name: String = self . input . get_text ( ) . into ( ) ;
210
+
211
+ self . input . clear ( ) ;
212
+ self . input . set_input_type ( InputType :: Multiline ) ;
213
+ self . input . set_title ( strings:: tag_popup_annotation_title (
214
+ & tag_name,
215
+ ) ) ;
216
+ self . input
217
+ . set_default_msg ( strings:: tag_popup_annotation_msg ( ) ) ;
218
+ self . mode = Mode :: Annotation { tag_name } ;
219
+ }
204
220
}
0 commit comments