-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from chrispahm/main-gms-statusbar
✨ add menubar item and commands for main gms file
- Loading branch information
Showing
6 changed files
with
167 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const checkIfExcluded = require('./checkIfExcluded'); | ||
const path = require('path'); | ||
const vscode = require('vscode'); | ||
|
||
module.exports = function updateStatusBar(gamsStatusBarItem) { | ||
const file = vscode.window.activeTextEditor?.document.fileName; | ||
const mainGmsFile = vscode.workspace.getConfiguration('gamsIde').get('mainGmsFile'); | ||
const excludedFiles = vscode.workspace.getConfiguration('gamsIde').get('excludeFromMainGmsFile'); | ||
const fileIsExcluded = checkIfExcluded(file, excludedFiles); | ||
const languageId = vscode.window.activeTextEditor?.document.languageId; | ||
if (languageId !== 'gams') { | ||
gamsStatusBarItem.hide(); | ||
} else if (fileIsExcluded && mainGmsFile) { | ||
gamsStatusBarItem.text = `Main GMS: File is excluded`; | ||
// open workspace settings.json -> excludeFromMainGmsFile | ||
gamsStatusBarItem.command = 'workbench.action.openWorkspaceSettingsFile'; | ||
gamsStatusBarItem.show(); | ||
} else if (mainGmsFile) { | ||
gamsStatusBarItem.text = `Main GMS: ${path.basename(mainGmsFile)}`; | ||
// open settings for mainGmsFile | ||
gamsStatusBarItem.command = 'gams.selectMainGmsFile'; | ||
gamsStatusBarItem.show(); | ||
} else { | ||
gamsStatusBarItem.hide(); | ||
} | ||
}; |