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

Empty source re-render Hotfix #912

Closed
wants to merge 1 commit into from
Closed
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
21 changes: 19 additions & 2 deletions src/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,25 @@ export default function Window({ application, session }) {

const lang = langs[language.toLowerCase()];
// Do nothing if there is no code to avoid compile errors
const text = lang.document.code_view.buffer.text.trim();
var text = lang.document.code_view.buffer.text.trim();
if (text === "") {
return;
// Using placeholder empty main functions and empty comments as source when empty
if (language === "JavaScript") {
text = "//"
}
else if (language === "Vala") {
// Set Compiler input as
lang.document.code_view.buffer.text = "#! /usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1\npublic void main() {\n}\n"
// Janky; Run needs to be pressed twice before it starts to re-render the preview
}
else if (language === "Rust") {
// Set Compiler input as
lang.document.code_view.buffer.text = "pub fn main() {}"
}
else if (language === "Python") {
// Set interpreter input as '#'
lang.document.code_view.buffer.text = "# Empty"
}
}

if (language === "JavaScript") {
Expand Down Expand Up @@ -508,3 +524,4 @@ async function promptSessionClose({ window }) {
location?.get_child_for_display_name(row_project_name.text),
];
}