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

Avoid wipeout of content on restart with opened editors #146

Merged
merged 1 commit into from
Feb 23, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Keep `Kaoto backend` output log available when Kaoto backend native executable cannot be launched. It allows to have more information what can be the issue.
- Upgrade embedded Kaoto [UI](https://github.com/KaotoIO/kaoto-ui/releases/tag/v0.6.1) to 0.6.1 and [backend](https://github.com/KaotoIO/kaoto-backend/releases/tag/v0.6.2) to 0.6.2
- Open Kaoto editor by default for `*.camel.(yaml|yml)` files
- Avoid wipeout of content on restart with opened editors #144

# 0.2.0

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@kie-tools-core/workspace": "^0.26.0",
"@patternfly/react-core": "4.267.6",
"@redhat-developer/vscode-redhat-telemetry": "^0.5.4",
"async-wait-until": "^2.0.12",
"react": "18.2.0",
"react-dom": "18.2.0"
},
Expand Down
14 changes: 12 additions & 2 deletions src/extension/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import { waitUntil } from 'async-wait-until';
import { backendI18nDefaults, backendI18nDictionaries } from "@kie-tools-core/backend/dist/i18n";
import { VsCodeBackendProxy } from "@kie-tools-core/backend/dist/vscode";
import { EditorEnvelopeLocator, EnvelopeContentType, EnvelopeMapping } from "@kie-tools-core/editor/dist/api";
Expand All @@ -31,6 +32,7 @@ let telemetryService: TelemetryService;

let backendProcess: child_process.ChildProcessWithoutNullStreams | undefined;
let kaotoBackendOutputChannel: vscode.OutputChannel | undefined;
let kaotoBackendWarmedUp: boolean = false;

export async function activate(context: vscode.ExtensionContext) {
console.info("Kaoto Editor extension is alive.");
Expand All @@ -57,6 +59,9 @@ export async function activate(context: vscode.ExtensionContext) {
if (kaotoBackendOutputChannel) {
const dec = new TextDecoder("utf-8");
const text = dec.decode(data);
if (!kaotoBackendWarmedUp && text.includes('Catalog class io.kaoto.backend.api.metadata.catalog.StepCatalog_Subclass warmed up in')) {
kaotoBackendWarmedUp = true;
}
kaotoBackendOutputChannel.append(text);
}
});
Expand All @@ -71,6 +76,12 @@ export async function activate(context: vscode.ExtensionContext) {
const backendI18n = new I18n(backendI18nDefaults, backendI18nDictionaries, vscode.env.language);
backendProxy = new VsCodeBackendProxy(context, backendI18n);

try {
await waitUntil(() => kaotoBackendWarmedUp, { timeout: 30000});
} catch {
kaotoBackendOutputChannel.append('Kaoto backend failed to warm up in 30 seconds.\n');
}

KogitoVsCode.startExtension({
extensionName: "redhat.vscode-kaoto",
context: context,
Expand All @@ -88,8 +99,6 @@ export async function activate(context: vscode.ExtensionContext) {
]),
backendProxy: backendProxy,
});

console.info("Extension is successfully setup.");

const redhatService = await getRedHatService(context);
telemetryService = await redhatService.getTelemetryService();
Expand All @@ -106,6 +115,7 @@ function getBinaryName(): string {
}

export function deactivate() {
kaotoBackendWarmedUp = false;
if (backendProcess !== undefined) {
if (kaotoBackendOutputChannel !== undefined) {
kaotoBackendOutputChannel.append(`Kaoto backend is stopped during VS Code extension deactivation.`);
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,11 @@ assertion-error@^1.1.0:
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b"
integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==

async-wait-until@^2.0.12:
version "2.0.12"
resolved "https://registry.yarnpkg.com/async-wait-until/-/async-wait-until-2.0.12.tgz#8a94683bf29e74642a8bcbb9385f6ea330d4383f"
integrity sha512-SXy/vDs6UPJMG6YeEYOQ4ilA/JnGxk187KPGqFx9O+qVxsjkSl+jH+3P50qSNyMpEmDgr8qOFGOKCJckWb1i7A==

async@^2.6.4:
version "2.6.4"
resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221"
Expand Down