Skip to content

Commit

Permalink
Improve logs, fix LibIncludeType.Disabled (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-wiemer authored Oct 17, 2024
1 parent d5a3f83 commit 297742e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ export function updateConfig(newConfig: AHKLSConfig): void {
globalScanExclude.file = file;
globalScanExclude.folder = folder;
console.log(`Excluded files:\n\t${globalScanExclude.file.map(re => re.source).join('\n\t') || '(none)'}`);
console.log(`Excluded folders\n\t ${globalScanExclude.folder.map(re => re.source).join('\n\t') || '(none)'}`);
console.log(`Excluded folders:\n\t${globalScanExclude.folder.map(re => re.source).join('\n\t') || '(none)'}`);
let maxScanDepth = getCfg<number | undefined>(CfgKey.MaxScanDepth, newConfig);
if (maxScanDepth === undefined) {
maxScanDepth = 2;
Expand Down
1 change: 1 addition & 0 deletions server/src/completionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ export async function completionProvider(params: CompletionParams, _token: Cance
// auto-include
const includeUserStdLib = shouldIncludeUserStdLib();
const includeLocalLib = shouldIncludeLocalLib();
console.log('includeUserStdLib:', includeUserStdLib, ', includeLocalLib:', includeLocalLib);
if (includeUserStdLib || includeLocalLib) {
const libdirs = doc.libdirs, caches: Record<string, TextEdit[]> = {};
let exportnum = 0, line = -1, first_is_comment: boolean | undefined, cm: Token;
Expand Down
8 changes: 8 additions & 0 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,14 @@ connection.onInitialized(() => {

connection.onDidChangeConfiguration(async change => {
let newConfig: AHKLSConfig | undefined = change?.settings;
console.log('Configuration changed');
if (hasConfigurationCapability && !newConfig)
newConfig = await connection.workspace.getConfiguration(configPrefix);
if (!newConfig) {
connection.window.showWarningMessage('Failed to obtain the configuration');
return;
}
console.log('New configuration:', newConfig);
// clone the old config to compare
const oldConfig = klona(getCfg<AHKLSConfig>());
updateConfig(newConfig); // this updates the object in-place, hence the clone above
Expand All @@ -175,7 +177,10 @@ connection.onDidChangeConfiguration(async change => {
if (shouldIncludeUserStdLib() && (excludeChanged || !shouldIncludeUserStdLib(oldConfig)))
parseuserlibs();
if (shouldIncludeLocalLib() && (excludeChanged || !shouldIncludeLocalLib(oldConfig)))
{
console.log('Parsing local libraries');
documents.all().forEach(e => parseproject(e.uri.toLowerCase()));
}
}
if (getCfg(CfgKey.Syntaxes) !== getCfg(CfgKey.Syntaxes, oldConfig)) {
initahk2cache(), loadAHK2();
Expand Down Expand Up @@ -388,6 +393,8 @@ async function parseuserlibs() {
uri: string,
d: Lexer,
t: TextDocument | undefined;
console.log('Parsing user libraries');
console.log('Libraries:\n\t', libdirs.join('\n\t'));
for (dir of libdirs)
for await (path of enum_ahkfiles(dir)) {
if (!libfuncs[(uri = URI.file(path).toString().toLowerCase())]) {
Expand Down Expand Up @@ -440,6 +447,7 @@ async function setInterpreter(path: string) {
}

async function parseproject(uri: string) {
console.log(`Parsing project: ${uri}`);
let lex = lexers[uri];
if (!lex || !uri.startsWith('file:')) return;
if (!lex.d) {
Expand Down
2 changes: 1 addition & 1 deletion util/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export type ActionType =
| 'Stop';

export enum LibIncludeType {
Disabled = 'Off',
Disabled = 'Disabled',
Local = 'Local',
UserAndStandard = 'User and Standard',
All = 'All',
Expand Down

0 comments on commit 297742e

Please sign in to comment.