Skip to content

Commit 9c9e8e6

Browse files
Pass escape press through when sig help is closed (#1049)
This allows CM's default escape, (shift+)tab behaviour to function. Closes #1048.
1 parent 1344128 commit 9c9e8e6

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/editor/codemirror/language-server/signatureHelp.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,6 @@ const signatureHelpToolTipBaseTheme = EditorView.baseTheme({
6363
},
6464
});
6565

66-
const closeSignatureHelp: Command = (view: EditorView) => {
67-
view.dispatch({
68-
effects: setSignatureHelpEffect.of({
69-
pos: -1,
70-
result: null,
71-
}),
72-
});
73-
return true;
74-
};
75-
7666
const triggerSignatureHelpRequest = async (view: EditorView): Promise<void> => {
7767
const uri = view.state.facet(uriFacet)!;
7868
const client = view.state.facet(clientFacet)!;
@@ -102,12 +92,6 @@ const openSignatureHelp: Command = (view: EditorView) => {
10292
return true;
10393
};
10494

105-
const signatureHelpKeymap: readonly KeyBinding[] = [
106-
// This matches VS Code.
107-
{ key: "Mod-Shift-Space", run: openSignatureHelp },
108-
{ key: "Escape", run: closeSignatureHelp },
109-
];
110-
11195
export const signatureHelp = (
11296
intl: IntlShape,
11397
automatic: boolean,
@@ -129,6 +113,25 @@ export const signatureHelp = (
129113
provide: (f) => showTooltip.from(f, (val) => val.tooltip),
130114
});
131115

116+
const closeSignatureHelp: Command = (view: EditorView) => {
117+
if (view.state.field(signatureHelpTooltipField).tooltip) {
118+
view.dispatch({
119+
effects: setSignatureHelpEffect.of({
120+
pos: -1,
121+
result: null,
122+
}),
123+
});
124+
return true;
125+
}
126+
return false;
127+
};
128+
129+
const signatureHelpKeymap: readonly KeyBinding[] = [
130+
// This matches VS Code.
131+
{ key: "Mod-Shift-Space", run: openSignatureHelp },
132+
{ key: "Escape", run: closeSignatureHelp },
133+
];
134+
132135
class SignatureHelpView
133136
extends BaseLanguageServerView
134137
implements PluginValue

0 commit comments

Comments
 (0)