[PATCH] D21181: [include-fixer] give users an option to show N more headers in case there are too many candidates.

Eric Liu via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 9 07:06:57 PDT 2016


ioeric created this revision.
ioeric added a reviewer: bkramer.
ioeric added a subscriber: cfe-commits.

give users an option to show N more headers in case there are too many candidates.

http://reviews.llvm.org/D21181

Files:
  include-fixer/tool/clang-include-fixer.py

Index: include-fixer/tool/clang-include-fixer.py
===================================================================
--- include-fixer/tool/clang-include-fixer.py
+++ include-fixer/tool/clang-include-fixer.py
@@ -34,14 +34,22 @@
       1,
       vim.eval('g:clang_include_fixer_maximum_suggested_headers'))
 
+increment_num=5
+if vim.eval('exists("g:clang_include_fixer_increment_num")') == "1":
+  increment_num = max(
+      1,
+      vim.eval('g:clang_include_fixer_increment_num'))
 
 def GetUserSelection(message, headers, maximum_suggested_headers):
   eval_message = message + '\n'
   for idx, header in enumerate(headers[0:maximum_suggested_headers]):
     eval_message += "({0}). {1}\n".format(idx+1, header)
   eval_message += "Enter (q) to quit;"
   if maximum_suggested_headers < len(headers):
-    eval_message += " (a) to show all candidates.";
+    eval_message += " (a) to show all {0} candidates;".format(len(headers))
+    if len(headers) - maximum_suggested_headers > increment_num:
+      eval_message += " (m) to show {0} more candidates.".format(increment_num)
+
   eval_message += "\nSelect (default 1): "
   res = vim.eval("input('{0}')".format(eval_message))
   if res == '':
@@ -51,6 +59,9 @@
     raise Exception('   Insertion cancelled...')
   elif res == 'a' and maximum_suggested_headers < len(headers):
     return GetUserSelection(message, headers, len(headers))
+  elif res == 'm':
+    return GetUserSelection(message,
+                            headers, maximum_suggested_headers + increment_num)
   else:
     try:
       idx = int(res)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21181.60167.patch
Type: text/x-patch
Size: 1575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160609/194f51ae/attachment-0001.bin>


More information about the cfe-commits mailing list