|
34 | 34 | 1,
|
35 | 35 | vim.eval('g:clang_include_fixer_maximum_suggested_headers'))
|
36 | 36 |
|
| 37 | +increment_num=5 |
| 38 | +if vim.eval('exists("g:clang_include_fixer_increment_num")') == "1": |
| 39 | + increment_num = max( |
| 40 | + 1, |
| 41 | + vim.eval('g:clang_include_fixer_increment_num')) |
37 | 42 |
|
38 | 43 | def GetUserSelection(message, headers, maximum_suggested_headers):
|
39 | 44 | eval_message = message + '\n'
|
40 | 45 | for idx, header in enumerate(headers[0:maximum_suggested_headers]):
|
41 | 46 | eval_message += "({0}). {1}\n".format(idx+1, header)
|
42 | 47 | eval_message += "Enter (q) to quit;"
|
43 | 48 | if maximum_suggested_headers < len(headers):
|
44 |
| - eval_message += " (a) to show all candidates."; |
| 49 | + eval_message += " (m) to show {0} more candidates.".format( |
| 50 | + min(increment_num, len(headers) - maximum_suggested_headers)) |
| 51 | + |
45 | 52 | eval_message += "\nSelect (default 1): "
|
46 | 53 | res = vim.eval("input('{0}')".format(eval_message))
|
47 | 54 | if res == '':
|
48 | 55 | # choose the top ranked header by default
|
49 | 56 | idx = 1
|
50 | 57 | elif res == 'q':
|
51 | 58 | raise Exception(' Insertion cancelled...')
|
52 |
| - elif res == 'a' and maximum_suggested_headers < len(headers): |
53 |
| - return GetUserSelection(message, headers, len(headers)) |
| 59 | + elif res == 'm': |
| 60 | + return GetUserSelection(message, |
| 61 | + headers, maximum_suggested_headers + increment_num) |
54 | 62 | else:
|
55 | 63 | try:
|
56 | 64 | idx = int(res)
|
57 | 65 | if idx <= 0 or idx > len(headers):
|
58 | 66 | raise Exception()
|
59 | 67 | except Exception:
|
60 |
| - raise Exception(' ERROR: Invalid option "{0}"...Abort!'.format(res)) |
| 68 | + # Show a new prompt on invalid option instead of aborting so that users |
| 69 | + # don't need to wait for another include-fixer run. |
| 70 | + print >> sys.stderr, "Invalid option:", res |
| 71 | + return GetUserSelection(message, headers, maximum_suggested_headers) |
61 | 72 | return headers[idx-1]
|
62 | 73 |
|
63 | 74 | def execute(command, text):
|
|
0 commit comments