Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show path error messages only on setting changes #173

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/ai_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const listeners = new Map();
let listenerId = 0;
let aiPath = '';
let _noEvents;
const isWinOS = process.platform === 'win32';
let showErrors = false;
workspace.onDidChangeConfiguration(({ affectsConfiguration }) => {
if (_noEvents || !affectsConfiguration('autoit')) return;

Expand All @@ -31,6 +33,7 @@ workspace.onDidChangeConfiguration(({ affectsConfiguration }) => {
console.error(er);
}
});
showErrors = isWinOS;
getPaths();
});

Expand Down Expand Up @@ -77,7 +80,12 @@ function verifyPath(path, data, msgSuffix) {
return workspace.fs.stat(Uri.parse(`file:///${data.fullPath}`)).then(stats => {
const type = (data.file !== undefined ? FileType.File : FileType.Directory) | FileType.SymbolicLink;
if (!(stats.type & type))
return showError(path, data, msgSuffix);
{
if (showErrors)
showError(path, data, msgSuffix);

return;
}

if (data.message) {
data.message.hide();
Expand All @@ -87,7 +95,9 @@ function verifyPath(path, data, msgSuffix) {
return path;

}).catch(() => {
showError(path, data, msgSuffix);
if (showErrors)
showError(path, data, msgSuffix);

});
}

Expand Down Expand Up @@ -147,7 +157,8 @@ function getPaths() {
const data = Object.assign({ fullPath: "" }, defaultPath.check);
updateFullPath(udfPath[k], data).then(filePath => {
if (!filePath && !(filePath = findFilepath(udfPath[k], true))) {
showError(udfPath[k], data, `${msgSuffix}.udfPath[${k}]`);
if (showErrors)
showError(udfPath[k], data, `${msgSuffix}.udfPath[${k}]`);
}
else
udfPath[k] = filePath;
Expand Down
17 changes: 13 additions & 4 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ import { parseAu3CheckOutput } from './diagnosticUtils';
import conf from './ai_config';

const { config } = conf;
const isWinOS = process.platform === 'win32';

let checkPathPrev;
const checkAutoItCode = (document, diagnosticCollection) => {
if (!isWinOS)
return;

let consoleOutput = '';

if (!config.enableDiagnostics) {
Expand All @@ -28,10 +33,14 @@ const checkAutoItCode = (document, diagnosticCollection) => {
return;
}

if (!existsSync(config.checkPath)) {
window.showErrorMessage(
'Invalid Check Path! Please review AutoIt settings (Check Path in UI, autoit.checkPath in JSON)',
);
const checkPath = config.checkPath;
if (!existsSync(checkPath)) {
if (checkPath !== checkPathPrev)
window.showErrorMessage(
'Invalid Check Path! Please review AutoIt settings (Check Path in UI, autoit.checkPath in JSON)',
);

checkPathPrev = checkPath;
return;
}
const checkProcess = spawn(config.checkPath, [document.fileName], {
Expand Down