mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-04 14:17:07 +00:00 
			
		
		
		
	Add completion.maxNum: 100
This commit is contained in:
		
							parent
							
								
									c7ee3d85f3
								
							
						
					
					
						commit
						38feb8d277
					
				@ -22,8 +22,6 @@ limitations under the License.
 | 
				
			|||||||
#include <clang/Lex/Lexer.h>
 | 
					#include <clang/Lex/Lexer.h>
 | 
				
			||||||
#include <llvm/Support/Path.h>
 | 
					#include <llvm/Support/Path.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <mutex>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
using namespace clang;
 | 
					using namespace clang;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
std::string PathFromFileEntry(const FileEntry &file) {
 | 
					std::string PathFromFileEntry(const FileEntry &file) {
 | 
				
			||||||
 | 
				
			|||||||
@ -130,6 +130,9 @@ struct Config {
 | 
				
			|||||||
    // that implement their own filtering and sorting logic.
 | 
					    // that implement their own filtering and sorting logic.
 | 
				
			||||||
    bool filterAndSort = true;
 | 
					    bool filterAndSort = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Maxmum number of results.
 | 
				
			||||||
 | 
					    int maxNum = 100;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    struct Include {
 | 
					    struct Include {
 | 
				
			||||||
      // Regex patterns to match include completion candidates against. They
 | 
					      // Regex patterns to match include completion candidates against. They
 | 
				
			||||||
      // receive the absolute file path.
 | 
					      // receive the absolute file path.
 | 
				
			||||||
@ -260,7 +263,8 @@ MAKE_REFLECT_STRUCT(Config::CodeLens, localVariables);
 | 
				
			|||||||
MAKE_REFLECT_STRUCT(Config::Completion::Include, blacklist, maxPathSize,
 | 
					MAKE_REFLECT_STRUCT(Config::Completion::Include, blacklist, maxPathSize,
 | 
				
			||||||
                    suffixWhitelist, whitelist);
 | 
					                    suffixWhitelist, whitelist);
 | 
				
			||||||
MAKE_REFLECT_STRUCT(Config::Completion, caseSensitivity, detailedLabel,
 | 
					MAKE_REFLECT_STRUCT(Config::Completion, caseSensitivity, detailedLabel,
 | 
				
			||||||
                    dropOldRequests, duplicateOptional, filterAndSort, include);
 | 
					                    dropOldRequests, duplicateOptional, filterAndSort, include,
 | 
				
			||||||
 | 
					                    maxNum);
 | 
				
			||||||
MAKE_REFLECT_STRUCT(Config::Diagnostics, blacklist, onChange, onOpen, onSave,
 | 
					MAKE_REFLECT_STRUCT(Config::Diagnostics, blacklist, onChange, onOpen, onSave,
 | 
				
			||||||
                    spellChecking, whitelist)
 | 
					                    spellChecking, whitelist)
 | 
				
			||||||
MAKE_REFLECT_STRUCT(Config::Highlight, largeFileSize, lsRanges, blacklist,
 | 
					MAKE_REFLECT_STRUCT(Config::Highlight, largeFileSize, lsRanges, blacklist,
 | 
				
			||||||
 | 
				
			|||||||
@ -182,9 +182,9 @@ void FilterAndSortCompletionResponse(
 | 
				
			|||||||
  auto &items = complete_response->result.items;
 | 
					  auto &items = complete_response->result.items;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  auto finalize = [&]() {
 | 
					  auto finalize = [&]() {
 | 
				
			||||||
    const size_t kMaxResultSize = 100u;
 | 
					    int max_num = g_config->completion.maxNum;
 | 
				
			||||||
    if (items.size() > kMaxResultSize) {
 | 
					    if (items.size() > max_num) {
 | 
				
			||||||
      items.resize(kMaxResultSize);
 | 
					      items.resize(max_num);
 | 
				
			||||||
      complete_response->result.isIncomplete = true;
 | 
					      complete_response->result.isIncomplete = true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user