Файли
openidea/sdk/rust/openidea-plugin/tests/api19_open_as_text.rs
T
l0ng-ai 7f32d04b19 feat(plugins): open files as text and contribute to Open In (API 1.19) (#6866)
Plugins can open a file in the built-in text editor even when a custom
editor claims it (workspace.editor open-as-text, SDK open_editor_as_text),
and commands can contribute to the Open In submenu (openIn menu location,
file as the argument, no submenus). Docs, versioning table and rebuilt
components included.

Fixes #6852
Fixes #6853
2026-11-30 00:32:41 +08:00

14 рядки
668 B
Rust

use openidea_plugin::{Error, host, mock::MockHost};
/// A custom editor's "view source" opens its file in the text editor, under `open`'s rules.
#[test]
fn a_project_file_opens_as_text() {
let mock = MockHost::install().with_capabilities(&[]);
mock.add_file("diagram.bpmn", "<definitions/>");
assert!(matches!(host::open_editor_as_text("diagram.bpmn", None), Err(Error::Denied(c)) if c == "project.read"));
let mock = mock.with_capabilities(&["project.read"]);
host::open_editor_as_text("diagram.bpmn", None).unwrap();
assert!(host::open_editor_as_text("../outside", None).is_err());
assert_eq!(mock.opened_as_text(), ["diagram.bpmn"]);
}