mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-15 17:56:06 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e61e3d71d |
No files matched your search
+2
-6
@@ -39,12 +39,8 @@ impl Plugin for Fixture {
|
||||
hover: None,
|
||||
after: Some(after.into()),
|
||||
};
|
||||
host::set_decorations(
|
||||
path,
|
||||
"fixture",
|
||||
&[item("typo", "typo message"), item("weak", "weak message")],
|
||||
)
|
||||
.map(|()| None)
|
||||
host::set_decorations(path, "fixture", &[item("typo", "typo message"), item("weak", "weak message")])
|
||||
.map(|()| None)
|
||||
}
|
||||
_ => Err(Error::NotFound(id.into())),
|
||||
}
|
||||
|
||||
@@ -25,19 +25,23 @@ describe("html bodies in the app", () => {
|
||||
expect(frame.getAttribute("sandbox")).toBe("allow-scripts");
|
||||
|
||||
const post = vi.spyOn(frame.contentWindow!, "postMessage");
|
||||
// Not from the frame: ignored.
|
||||
window.dispatchEvent(new MessageEvent("message", { data: { tag: FRAME_TAG, ready: true }, source: window }));
|
||||
expect(post).not.toHaveBeenCalled();
|
||||
|
||||
window.dispatchEvent(
|
||||
new MessageEvent("message", { data: { tag: FRAME_TAG, ready: true }, source: frame.contentWindow }),
|
||||
);
|
||||
expect(post).toHaveBeenCalledWith(
|
||||
{ tag: FRAME_TAG, document: expect.stringContaining("<p>chart</p><script>draw()</script>") },
|
||||
"*",
|
||||
);
|
||||
const ready = (source: Window | null) =>
|
||||
window.dispatchEvent(new MessageEvent("message", { data: { tag: FRAME_TAG, ready: true }, source }));
|
||||
// The listener is added in an effect that can run after the frame is in the DOM.
|
||||
await waitFor(() => {
|
||||
ready(frame.contentWindow);
|
||||
expect(post).toHaveBeenCalledWith(
|
||||
{ tag: FRAME_TAG, document: expect.stringContaining("<p>chart</p><script>draw()</script>") },
|
||||
"*",
|
||||
);
|
||||
});
|
||||
const doc = (post.mock.calls[0]![0] as { document: string }).document;
|
||||
expect(doc).toContain('<meta http-equiv="Content-Security-Policy"');
|
||||
expect(doc).toContain("window.openidea");
|
||||
|
||||
// Not from the frame: ignored.
|
||||
post.mockClear();
|
||||
ready(window);
|
||||
expect(post).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -680,6 +680,21 @@ export function DiffEditor({
|
||||
|
||||
useEffect(() => viewsRef.current?.panes?.setSync(opts.syncScroll), [opts.syncScroll]);
|
||||
|
||||
// The editor area focuses the tab's host (`[data-editor-focus]`), e.g. after F7 opened the next
|
||||
// file: hand that focus on to the diff, so its keymap and Jump to Source apply right away.
|
||||
useEffect(() => {
|
||||
const host = rootRef.current?.closest<HTMLElement>("[data-editor-focus]");
|
||||
const views = viewsRef.current;
|
||||
if (!host || !views) return;
|
||||
const forward = () => (focusedSide.current === "a" && views.a ? views.a : views.b).focus();
|
||||
const onFocus = (e: FocusEvent) => {
|
||||
if (e.target === host) forward();
|
||||
};
|
||||
host.addEventListener("focus", onFocus);
|
||||
if (document.activeElement === host) forward();
|
||||
return () => host.removeEventListener("focus", onFocus);
|
||||
}, [viewsGen]);
|
||||
|
||||
useEffect(
|
||||
() => () => {
|
||||
viewsRef.current?.destroy();
|
||||
|
||||
Reference in new issue
Block a user