File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -29,13 +29,18 @@ function PriorityState:prompt_user()
29
29
local choice = vim .fn .input (prompt )
30
30
31
31
if choice == ' ' then
32
+ utils .echo_warning (string.format (" Priority must be between '%s' and '%s'" , self .high_priority , self .low_priority ))
32
33
return nil
33
34
end
34
35
35
36
choice = string.upper (choice )
37
+ if # choice > 1 and tonumber (choice ) == nil then
38
+ utils .echo_warning (string.format (' Only numeric priorities can be multiple characters long' ))
39
+ return nil
40
+ end
36
41
local choicenum = string.byte (choice )
37
42
if choice ~= ' ' and (choicenum < string.byte (self .high_priority ) or choicenum > string.byte (self .low_priority )) then
38
- utils .echo_warning (string.format (" Priority must be between '%s' and '%s'" , self .low_priority , self .high_priority ))
43
+ utils .echo_warning (string.format (" Priority must be between '%s' and '%s'" , self .high_priority , self .low_priority ))
39
44
return nil
40
45
end
41
46
Original file line number Diff line number Diff line change @@ -327,6 +327,9 @@ function OrgMappings:set_priority(direction)
327
327
new_priority = priority_state :decrease ()
328
328
elseif direction == nil then
329
329
new_priority = priority_state :prompt_user ()
330
+ if new_priority == nil then
331
+ return
332
+ end
330
333
end
331
334
332
335
headline :set_priority (new_priority )
Original file line number Diff line number Diff line change @@ -91,6 +91,12 @@ function Headline:set_priority(priority)
91
91
return
92
92
end
93
93
94
+ -- TODO: input validation is split between here and priority_state.lua:prompt_user().
95
+ -- should be unified
96
+ if vim .trim (priority ) == ' ' then
97
+ return
98
+ end
99
+
94
100
local todo = self :todo ()
95
101
if todo then
96
102
local text = query .get_node_text (todo , 0 )
You can’t perform that action at this time.
0 commit comments