mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-18 03:36:18 +00:00
[ty] Fix Escape handler in playground (#21397)
This commit is contained in:
parent
725ae69773
commit
19c7994e90
1 changed files with 22 additions and 9 deletions
|
|
@ -70,13 +70,16 @@ export default function Editor({
|
||||||
const serverRef = useRef<PlaygroundServer | null>(null);
|
const serverRef = useRef<PlaygroundServer | null>(null);
|
||||||
|
|
||||||
if (serverRef.current != null) {
|
if (serverRef.current != null) {
|
||||||
serverRef.current.update({
|
serverRef.current.update(
|
||||||
|
{
|
||||||
files,
|
files,
|
||||||
workspace,
|
workspace,
|
||||||
onOpenFile,
|
onOpenFile,
|
||||||
onVendoredFileChange,
|
onVendoredFileChange,
|
||||||
onBackToUserFile,
|
onBackToUserFile,
|
||||||
});
|
},
|
||||||
|
isViewingVendoredFile,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the diagnostics in the editor.
|
// Update the diagnostics in the editor.
|
||||||
|
|
@ -200,6 +203,7 @@ class PlaygroundServer
|
||||||
private rangeSemanticTokensDisposable: IDisposable;
|
private rangeSemanticTokensDisposable: IDisposable;
|
||||||
private signatureHelpDisposable: IDisposable;
|
private signatureHelpDisposable: IDisposable;
|
||||||
private documentHighlightDisposable: IDisposable;
|
private documentHighlightDisposable: IDisposable;
|
||||||
|
private inVendoredFileCondition: editor.IContextKey<boolean>;
|
||||||
// Cache for vendored file handles
|
// Cache for vendored file handles
|
||||||
private vendoredFileHandles = new Map<string, FileHandle>();
|
private vendoredFileHandles = new Map<string, FileHandle>();
|
||||||
|
|
||||||
|
|
@ -249,8 +253,16 @@ class PlaygroundServer
|
||||||
this.documentHighlightDisposable =
|
this.documentHighlightDisposable =
|
||||||
monaco.languages.registerDocumentHighlightProvider("python", this);
|
monaco.languages.registerDocumentHighlightProvider("python", this);
|
||||||
|
|
||||||
|
this.inVendoredFileCondition = editor.createContextKey<boolean>(
|
||||||
|
"inVendoredFile",
|
||||||
|
false,
|
||||||
|
);
|
||||||
// Register Esc key command
|
// Register Esc key command
|
||||||
editor.addCommand(monaco.KeyCode.Escape, this.props.onBackToUserFile);
|
editor.addCommand(
|
||||||
|
monaco.KeyCode.Escape,
|
||||||
|
() => this.props.onBackToUserFile(),
|
||||||
|
"inVendoredFile",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
triggerCharacters: string[] = ["."];
|
triggerCharacters: string[] = ["."];
|
||||||
|
|
@ -452,8 +464,9 @@ class PlaygroundServer
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
update(props: PlaygroundServerProps) {
|
update(props: PlaygroundServerProps, isViewingVendoredFile: boolean) {
|
||||||
this.props = props;
|
this.props = props;
|
||||||
|
this.inVendoredFileCondition.set(isViewingVendoredFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getOrCreateVendoredFileHandle(vendoredPath: string): FileHandle {
|
private getOrCreateVendoredFileHandle(vendoredPath: string): FileHandle {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue