diff --git a/src/output_channels/OutputChannelDriver_Modal.ts b/src/output_channels/OutputChannelDriver_Modal.ts index 4d86b5f4..6cb7c193 100644 --- a/src/output_channels/OutputChannelDriver_Modal.ts +++ b/src/output_channels/OutputChannelDriver_Modal.ts @@ -115,21 +115,24 @@ class OutputModal extends Modal { // Ensure this channel is not excluded if (!excluded_output_channels.contains(output_channel_name)) { const output_channel_driver = output_channel_drivers[output_channel_name]; - redirect_setting.addButton(button => button - .setButtonText(output_channel_driver.getTitle(output_stream)) - .onClick(() => { - // Redirect output to the selected driver - const output_streams: OutputStreams = {}; - const textarea_element = textarea_setting.settingEl.find("textarea") as HTMLTextAreaElement; - output_streams[output_stream] = - getSelectionFromTextarea(textarea_element, true) // Use the selection, or... - ?? output_textarea.getValue() // ...use the whole text, if nothing is selected. - ; - output_channel_driver.initialize(this.plugin, this.t_shell_command, this.shell_command_parsing_result); - output_channel_driver.handle(output_streams, this.exit_code); - textarea_element.focus(); // Bring the focus back to the textarea in order to show a possible highlight (=selection) again. - }), - ); + // Ensure the output channel accepts this output stream. E.g. OutputChannelDriver_OpenFiles does not accept "stderr". + if (output_channel_driver.acceptsOutputStream(output_stream)) { + redirect_setting.addButton(button => button + .setButtonText(output_channel_driver.getTitle(output_stream)) + .onClick(() => { + // Redirect output to the selected driver + const output_streams: OutputStreams = {}; + const textarea_element = textarea_setting.settingEl.find("textarea") as HTMLTextAreaElement; + output_streams[output_stream] = + getSelectionFromTextarea(textarea_element, true) // Use the selection, or... + ?? output_textarea.getValue() // ...use the whole text, if nothing is selected. + ; + output_channel_driver.initialize(this.plugin, this.t_shell_command, this.shell_command_parsing_result); + output_channel_driver.handle(output_streams, this.exit_code); + textarea_element.focus(); // Bring the focus back to the textarea in order to show a possible highlight (=selection) again. + }), + ); + } } });