From a97cadea0d3545071edb08fc0f8bc431008872a2 Mon Sep 17 00:00:00 2001 From: Johnny Cheng Date: Fri, 11 Mar 2022 11:45:17 +0800 Subject: [PATCH 1/2] add simple fuzzy feature for searching workspace symbols fix #27 Signed-off-by: Johnny Cheng --- src/global/global.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/global/global.ts b/src/global/global.ts index 4341393..27a0020 100644 --- a/src/global/global.ts +++ b/src/global/global.ts @@ -171,8 +171,8 @@ export default class Global extends executableBase { async provideWorkspaceSymbols(query: string) : Promise { - const word = query + '*'; - let cmd: string[] = ['--encode-path', '" "', '-xa', word, '| head -300']; + const word = query.split('').join('.*') + '.*' + let cmd: string[] = ['--encode-path', '" "', '-xa', word]; let lines = await this.execute_async(cmd, vscode.workspace.rootPath, this.saved_env); return mapNoneEmpty(lines, (line) => { From e971846f40f47a92984890a45f39670ed28997ef Mon Sep 17 00:00:00 2001 From: Johnny Cheng Date: Fri, 11 Mar 2022 12:23:42 +0800 Subject: [PATCH 2/2] add gtagsLimitCommand option to limit the output result Signed-off-by: Johnny Cheng --- README.md | 4 ++++ package.json | 8 ++++++++ src/configuration.ts | 2 ++ src/global/global.ts | 3 +++ 4 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 28cdeda..b63a6af 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,10 @@ This extension is forked/rewriten from [C/C++ Intellisense](https://marketplace. * `gnuGlobal.gtagsExecutable` * Specify the path to the gtags. Default is 'gtags'. +* `gnuGlobal.gtagsLimitCommand` + * Specify the command pipe into Global tag search result to limit the maximum line count. + * Default is: `head -300`, for Windows users may set to: `more` for CMD or `Select-Object -first 300` for PowerShell. + * `gnuGlobal.objDirPrefix` * If objDirPrefix is set and objDirPrefix directory exists, gtags creates objDirPrefix/project_dir directory and makes tag files in it. Global will also try to search tag files in that directory. * This option is useful if you don't wan't to create tag files in your project directory. diff --git a/package.json b/package.json index ffcb996..990ac03 100644 --- a/package.json +++ b/package.json @@ -89,6 +89,14 @@ "scope": "machine", "description": "Specify the path to the gtags." }, + "gnuGlobal.gtagsLimitCommand": { + "type": [ + "string" + ], + "default": "head -300", + "scope": "resource", + "description": "Specify the command pipe into Global tag search result to limit the maximum line count." + }, "gnuGlobal.libraryPath": { "type": [ "array" diff --git a/src/configuration.ts b/src/configuration.ts index d4beb58..f474260 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -81,6 +81,8 @@ export default class GlobalConfiguration { readonly debugMode = new WindowScopeEnumConfig('gnuGlobal.debugMode', BoolOption, BoolDefault.Disabled); + readonly gtagsLimitCommand = new WindowScopeConfig('gnuGlobal.gtagsLimitCommand', 'head -300'); + /* resource scope configurations */ readonly autoUpdate = new ResourceScopeEnumConfig('gnuGlobal.autoUpdate', BoolDefault, BoolDefault.Default); diff --git a/src/global/global.ts b/src/global/global.ts index 27a0020..a7a1b06 100644 --- a/src/global/global.ts +++ b/src/global/global.ts @@ -173,6 +173,9 @@ export default class Global extends executableBase { : Promise { const word = query.split('').join('.*') + '.*' let cmd: string[] = ['--encode-path', '" "', '-xa', word]; + if (this.configuration.gtagsLimitCommand.get().length) { + cmd.push('|' + this.configuration.gtagsLimitCommand.get()) + } let lines = await this.execute_async(cmd, vscode.workspace.rootPath, this.saved_env); return mapNoneEmpty(lines, (line) => {