Skip to content

Commit

Permalink
keep focus
Browse files Browse the repository at this point in the history
  • Loading branch information
idleberg committed Mar 22, 2024
1 parent 53a5ee8 commit 492adc1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 29 deletions.
8 changes: 3 additions & 5 deletions src/diagnostics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as NSIS from 'makensis';
import { compile } from 'makensis';
import { findErrors, findWarnings, getMakensisPath, getNullDevice, getPreprocessMode, getOverrideCompression, getSpawnEnv } from './util';
import { getConfig } from 'vscode-get-config';
import micromatch from 'micromatch';
Expand Down Expand Up @@ -36,7 +36,7 @@ export async function updateDiagnostics(document: TextDocument | null, collectio
return;
}

const options: NSIS.CompilerOptions = {
const options: Makensis.CompilerOptions = {
verbose: 2,
pathToMakensis,
postExecute: [
Expand All @@ -61,7 +61,7 @@ export async function updateDiagnostics(document: TextDocument | null, collectio
let output;

try {
output = await NSIS.compile(document.fileName, options, await getSpawnEnv());
output = await compile(document.fileName, options, await getSpawnEnv());
} catch (error) {
console.error('[vscode-nsis]', error instanceof Error ? error.message : error);
}
Expand All @@ -82,6 +82,4 @@ export async function updateDiagnostics(document: TextDocument | null, collectio
} else {
collection.clear();
}

NSIS.events.removeAllListeners();
}
14 changes: 7 additions & 7 deletions src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function compilerOutputHandler(data: CompilerOutput): Promise<void>
nsisChannel.appendLine(data.line);

if (showOutputView === 'Always') {
nsisChannel.show();
nsisChannel.show(true);
}
}

Expand All @@ -21,7 +21,7 @@ export async function compilerErrorHandler(data: CompilerOutput): Promise<void>
nsisChannel.appendLine(data.line);

if (showOutputView === 'On Errors') {
nsisChannel.show();
nsisChannel.show(true);
}
}

Expand All @@ -30,7 +30,7 @@ export async function compilerExitHandler(data: CompilerOutput): Promise<void> {

if (data['status'] === 0) {
if (showOutputView === 'Always') {
nsisChannel.show();
nsisChannel.show(true);
}

const outfileExists = await fileExists(String(data.outFile));
Expand All @@ -45,7 +45,7 @@ export async function compilerExitHandler(data: CompilerOutput): Promise<void> {

if (data['warnings'] && showNotifications) {
if (showOutputView === 'On Warnings & Errors') {
nsisChannel.show();
nsisChannel.show(true);
}

const choice = await window.showWarningMessage(`Compiled with warnings`, openButton, revealButton);
Expand All @@ -56,7 +56,7 @@ export async function compilerExitHandler(data: CompilerOutput): Promise<void> {
}
} else if (showNotifications) {
if (showOutputView !== 'Never') {
nsisChannel.show();
nsisChannel.show(true);
}

if (showNotifications) {
Expand All @@ -80,7 +80,7 @@ export async function flagsHandler(data: unknown): Promise<void> {
);

nsisChannel.append(message);
nsisChannel.show();
nsisChannel.show(true);
}

export async function versionHandler(data: unknown): Promise<void> {
Expand All @@ -94,6 +94,6 @@ export async function versionHandler(data: unknown): Promise<void> {
window.showInformationMessage(message);
} else {
nsisChannel.append(message);
nsisChannel.show();
nsisChannel.show(true);
}
}
21 changes: 5 additions & 16 deletions src/makensis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,16 @@ export async function compile(strictMode: boolean): Promise<void> {

nsisChannel.clear();

NSIS.events.on('stdout', async data => await compilerOutputHandler(data));
NSIS.events.on('stderr', async data => await compilerErrorHandler(data));
NSIS.events.once('exit', async data => await compilerExitHandler(data));

try {
await NSIS.compile(
document.fileName,
{
env: await getProjectPath() || false,
events: true,
json: showFlagsAsObject,
onData: async data => await compilerOutputHandler(data),
onError: async data => await compilerErrorHandler(data),
onClose: async data => await compilerExitHandler(data),
pathToMakensis: await getMakensisPath(),
rawArguments: compiler.customArguments,
strict: strictMode || compiler.strictMode,
Expand All @@ -76,19 +75,16 @@ export async function compile(strictMode: boolean): Promise<void> {
} catch (error) {
console.error('[vscode-nsis]', error instanceof Error ? error.message : error);
}

NSIS.events.removeAllListeners();
}

export async function showVersion(): Promise<void> {
await nsisChannel.clear();

NSIS.events.once('exit', versionHandler);

try {
await NSIS.version(
{
events: true,
onClose: async data => await versionHandler(data),
pathToMakensis: await getMakensisPath()
},
await getSpawnEnv()
Expand All @@ -97,8 +93,6 @@ export async function showVersion(): Promise<void> {
} catch (error) {
console.error('[vscode-nsis]', error instanceof Error ? error.message : error);
}

NSIS.events.removeAllListeners();
}

export async function showCompilerFlags(): Promise<void> {
Expand All @@ -107,22 +101,19 @@ export async function showCompilerFlags(): Promise<void> {

await nsisChannel.clear();

NSIS.events.once('exit', flagsHandler);

try {
await NSIS.headerInfo(
{
events: true,
json: showFlagsAsObject || false,
onClose: flagsHandler,
pathToMakensis: pathToMakensis || undefined
},
await getSpawnEnv()
);
} catch (error) {
console.error('[vscode-nsis]', error instanceof Error ? error.message : error);
}

NSIS.events.removeAllListeners();
}

export async function showHelp(): Promise<void> {
Expand Down Expand Up @@ -157,6 +148,4 @@ export async function showHelp(): Promise<void> {
} catch (error) {
console.error('[vscode-nsis]', error instanceof error ? error.message : error);
}

NSIS.events.removeAllListeners();
}
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export async function buttonHandler(choice: string, outFile?: string): Promise<v
break;

case 'Show Output':
nsisChannel.show();
nsisChannel.show(true);
break;
}
}
Expand Down

0 comments on commit 492adc1

Please sign in to comment.