Skip to content

Commit 0106868

Browse files
committed
Show user path if no workspace path exists when editing the php path
1 parent 42e938f commit 0106868

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

extensions/php/src/phpMain.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function activate(context: vscode.ExtensionContext): any {
8686
}
8787

8888
function updateStatusBarItem(context: vscode.ExtensionContext, editor: vscode.TextEditor = vscode.window.activeTextEditor): void {
89-
statusBarItem.tooltip = context.workspaceState.get<string>(PathKey, undefined) || vscode.workspace.getConfiguration('php.validate').get('executablePath', undefined);
89+
statusBarItem.tooltip = getExecutablePath(context);
9090
if (editor && editor.document && editor.document.languageId === 'php') {
9191
statusBarItem.show();
9292
} else {
@@ -95,7 +95,7 @@ function updateStatusBarItem(context: vscode.ExtensionContext, editor: vscode.Te
9595
}
9696

9797
function onPathClicked(context: vscode.ExtensionContext, validator: PHPValidationProvider) {
98-
let value = context.workspaceState.get<string>(PathKey);
98+
let value = getExecutablePath(context);
9999
vscode.window.showInputBox({ prompt: localize('php.enterPath', 'The path to the PHP executable'), value: value || '' }).then(value => {
100100
if (!value) {
101101
// User pressed Escape
@@ -108,6 +108,18 @@ function onPathClicked(context: vscode.ExtensionContext, validator: PHPValidatio
108108
});
109109
}
110110

111+
function getExecutablePath(context: vscode.ExtensionContext): string {
112+
let result = context.workspaceState.get<string>(PathKey, undefined);
113+
if (result) {
114+
return result;
115+
}
116+
let section = vscode.workspace.getConfiguration('php.validate');
117+
if (section) {
118+
return section.get('executablePath', undefined);
119+
}
120+
return undefined;
121+
}
122+
111123
function migrateExecutablePath(settingsExecutablePath: string): Thenable<string> {
112124
return vscode.window.showInputBox(
113125
{

0 commit comments

Comments
 (0)