File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 66
77import * as vscode from 'vscode' ;
88import { CommentPattern } from './languageConfig' ;
9- import { getExtensionFilePath } from '../common' ;
9+ import { getExtensionFilePath , getCachedClangFormatPath , setCachedClangFormatPath } from '../common' ;
1010import * as os from 'os' ;
1111import * as which from 'which' ;
1212import { execSync } from 'child_process' ;
@@ -74,7 +74,15 @@ export class CppSettings extends Settings {
7474 public get clangFormatPath ( ) : string | undefined {
7575 let path : string | undefined | null = super . Section . get < string > ( "clang_format_path" ) ;
7676 if ( ! path ) {
77+ const cachedClangFormatPath : string | null | undefined = getCachedClangFormatPath ( ) ;
78+ if ( cachedClangFormatPath !== undefined ) {
79+ if ( cachedClangFormatPath === null ) {
80+ return undefined ;
81+ }
82+ return cachedClangFormatPath ;
83+ }
7784 path = which . sync ( 'clang-format' , { nothrow : true } ) ;
85+ setCachedClangFormatPath ( path ) ;
7886 if ( ! path ) {
7987 return undefined ;
8088 } else {
Original file line number Diff line number Diff line change @@ -45,6 +45,14 @@ export function setExtensionPath(path: string): void {
4545 extensionPath = path ;
4646}
4747
48+ let cachedClangFormatPath : string | null | undefined ;
49+ export function getCachedClangFormatPath ( ) : string | null | undefined {
50+ return cachedClangFormatPath ;
51+ }
52+ export function setCachedClangFormatPath ( path : string | null ) : void {
53+ cachedClangFormatPath = path ;
54+ }
55+
4856// Use this package.json to read values
4957export const packageJson : any = vscode . extensions . getExtension ( "ms-vscode.cpptools" ) ?. packageJSON ;
5058
You can’t perform that action at this time.
0 commit comments