Skip to content

Commit 4394a3e

Browse files
authored
Squash fix unhandled promise rejection when using markup v22 (#68)
Method `location.output[index].set_use_markup` doesn't exist. But without the exception thrown by its use, the call to `location.output[index].set_text` overwrites markup settings. Ensure that only markup or normal text is set, but not both.
1 parent 684c874 commit 4394a3e

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

extension.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -337,29 +337,27 @@ function resetOutput(location) {
337337
async function setOutput(location, index) {
338338
let executorRegex = new RegExp(/(<executor\..*?\..*?>)/g);
339339
let executorSettingsArray = location.commandsOutput[index].match(executorRegex);
340+
let markupSet = false;
340341

341-
location.output[index].set_text(location.commandsOutput[index]);
342342
location.output[index].set_style_class_name("");
343343

344344
if (executorSettingsArray != null) {
345345
executorSettingsArray.forEach(setting => {
346346
location.commandsOutput[index] = location.commandsOutput[index].replace(setting, "");
347-
})
348-
349-
executorSettingsArray.forEach(setting => {
347+
350348
let settingDivided = setting.substring(1, setting.length - 1).split(".");
351349

352350
if (settingDivided[1] == "css") {
353351
location.output[index].add_style_class_name(settingDivided[2])
354-
}
355-
356-
if (settingDivided[1] == "markup") {
357-
location.output[index].get_clutter_text().set_text(location.commandsOutput[index]);
358-
location.output[index].get_clutter_text().set_use_markup(true);
359-
location.output[index].set_use_markup(true);
352+
} else if (settingDivided[1] == "markup") {
353+
markupSet = true
360354
}
361355
})
362356
}
363357

364-
location.output[index].set_text(location.commandsOutput[index]);
358+
if (markupSet) {
359+
location.output[index].get_clutter_text().set_markup(location.commandsOutput[index]);
360+
} else {
361+
location.output[index].set_text(location.commandsOutput[index]);
362+
}
365363
}

0 commit comments

Comments
 (0)