File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -147,17 +147,27 @@ func (p *Parser) parseTime() string {
147147func (p * Parser ) parseCtrl () Command {
148148 var args []string
149149
150+ inModifierChain := true
150151 for p .peek .Type == PLUS {
151152 p .nextToken ()
152153 peek := p .peek
153154
154155 // Get key from keywords and check if it's a valid modifier
155156 if k := keywords [peek .Literal ]; IsModifier (k ) {
157+ if ! inModifierChain {
158+ p .errors = append (p .errors , NewError (p .cur , "Modifiers must come before other characters" ))
159+ // Clear args so the error is returned
160+ args = nil
161+ continue
162+ }
163+
156164 args = append (args , peek .Literal )
157165 p .nextToken ()
158166 continue
159167 }
160168
169+ inModifierChain = false
170+
161171 // Add key argument.
162172 switch {
163173 case peek .Type == ENTER ,
Original file line number Diff line number Diff line change @@ -220,10 +220,14 @@ func TestParseCtrl(t *testing.T) {
220220 wantErr : false ,
221221 },
222222 {
223- name : "should parse with out of order modifiers" ,
224- tape : "Ctrl+Shift+C+Alt" ,
225- wantArgs : []string {"Shift" , "C" , "Alt" },
226- wantErr : false ,
223+ name : "should not parse with out of order modifiers" ,
224+ tape : "Ctrl+Shift+C+Alt" ,
225+ wantErr : true ,
226+ },
227+ {
228+ name : "should not parse with out of order modifiers" ,
229+ tape : "Ctrl+Shift+C+Alt+C" ,
230+ wantErr : true ,
227231 },
228232 {
229233 tape : "Ctrl+Alt+Right" ,
You can’t perform that action at this time.
0 commit comments