diff --git a/browser/src/Plugins/Api/Oni.ts b/browser/src/Plugins/Api/Oni.ts index 70c7cc528a..552e1961ea 100644 --- a/browser/src/Plugins/Api/Oni.ts +++ b/browser/src/Plugins/Api/Oni.ts @@ -178,6 +178,8 @@ export class Oni extends EventEmitter implements Oni.Plugin.Api { info: quickInfo.title, documentation: quickInfo.description, }) + } else { + this._channel.send("clear-quick-info", originalContext, null) } }, (err) => { this._channel.sendError("show-quick-info", originalContext, err) diff --git a/browser/src/Plugins/PluginManager.ts b/browser/src/Plugins/PluginManager.ts index fb906408e1..ef236545d7 100644 --- a/browser/src/Plugins/PluginManager.ts +++ b/browser/src/Plugins/PluginManager.ts @@ -158,80 +158,82 @@ export class PluginManager extends EventEmitter { // TODO: Refactor these handlers to separate classes // - pluginManager.registerResponseHandler("show-quick-info", new QuickInfoHandler()) - switch (pluginResponse.type) { - case "show-quick-info": - if (!this._validateOriginEventMatchesCurrentEvent(pluginResponse)) { - return - } - - if (!pluginResponse.error) { + case "clear-quick-info": UI.Actions.hideQuickInfo() - setTimeout(() => { - if (!this._validateOriginEventMatchesCurrentEvent(pluginResponse)) { - return - } - UI.Actions.showQuickInfo(pluginResponse.payload.info, pluginResponse.payload.documentation) - }, this._config.getValue("editor.quickInfo.delay")) - } else { - setTimeout(() => UI.Actions.hideQuickInfo()) - } - break - case "goto-definition": - if (!this._validateOriginEventMatchesCurrentEvent(pluginResponse)) { - return - } - - // TODO: Refactor to 'Service', break remaining NeoVim dependencies - const { filePath, line, column } = pluginResponse.payload - this._neovimInstance.command("e! " + filePath) - this._neovimInstance.command(`cal cursor(${line}, ${column})`) - this._neovimInstance.command("norm zz") - break - case "completion-provider": - if (!this._validateOriginEventMatchesCurrentEvent(pluginResponse)) { - return - } - - if (!pluginResponse.payload) { - return - } - - setTimeout(() => UI.Actions.showCompletions(pluginResponse.payload)) - break - case "completion-provider-item-selected": - setTimeout(() => UI.Actions.setDetailedCompletionEntry(pluginResponse.payload.details)) - break - case "set-errors": - this.emit("set-errors", pluginResponse.payload.key, pluginResponse.payload.fileName, pluginResponse.payload.errors, pluginResponse.payload.color) - break - case "find-all-references": - this.emit("find-all-references", pluginResponse.payload.references) - break - case "format": - this.emit("format", pluginResponse.payload) - break - case "execute-shell-command": - // TODO: Check plugin permission - this.emit("execute-shell-command", pluginResponse.payload) - break - case "evaluate-block-result": - this.emit("evaluate-block-result", pluginResponse.payload) - break - case "set-syntax-highlights": - this.emit("set-syntax-highlights", pluginResponse.payload) - break - case "clear-syntax-highlights": - this.emit("clear-syntax-highlights", pluginResponse.payload) - break - case "signature-help-response": - this.emit("signature-help-response", pluginResponse.error, pluginResponse.payload) - break - case "redux-action": - UI.store.dispatch(pluginResponse.payload) - break - default: - this.emit("logWarning", "Unexpected plugin type: " + pluginResponse.type) + break + case "show-quick-info": + if (!this._validateOriginEventMatchesCurrentEvent(pluginResponse)) { + return + } + + if (!pluginResponse.error) { + UI.Actions.hideQuickInfo() + setTimeout(() => { + if (!this._validateOriginEventMatchesCurrentEvent(pluginResponse)) { + return + } + UI.Actions.showQuickInfo(pluginResponse.payload.info, pluginResponse.payload.documentation) + }, this._config.getValue("editor.quickInfo.delay")) + } else { + setTimeout(() => UI.Actions.hideQuickInfo()) + } + break + case "goto-definition": + if (!this._validateOriginEventMatchesCurrentEvent(pluginResponse)) { + return + } + + // TODO: Refactor to 'Service', break remaining NeoVim dependencies + const { filePath, line, column } = pluginResponse.payload + this._neovimInstance.command("e! " + filePath) + this._neovimInstance.command(`cal cursor(${line}, ${column})`) + this._neovimInstance.command("norm zz") + break + case "completion-provider": + if (!this._validateOriginEventMatchesCurrentEvent(pluginResponse)) { + return + } + + if (!pluginResponse.payload) { + return + } + + setTimeout(() => UI.Actions.showCompletions(pluginResponse.payload)) + break + case "completion-provider-item-selected": + setTimeout(() => UI.Actions.setDetailedCompletionEntry(pluginResponse.payload.details)) + break + case "set-errors": + this.emit("set-errors", pluginResponse.payload.key, pluginResponse.payload.fileName, pluginResponse.payload.errors, pluginResponse.payload.color) + break + case "find-all-references": + this.emit("find-all-references", pluginResponse.payload.references) + break + case "format": + this.emit("format", pluginResponse.payload) + break + case "execute-shell-command": + // TODO: Check plugin permission + this.emit("execute-shell-command", pluginResponse.payload) + break + case "evaluate-block-result": + this.emit("evaluate-block-result", pluginResponse.payload) + break + case "set-syntax-highlights": + this.emit("set-syntax-highlights", pluginResponse.payload) + break + case "clear-syntax-highlights": + this.emit("clear-syntax-highlights", pluginResponse.payload) + break + case "signature-help-response": + this.emit("signature-help-response", pluginResponse.error, pluginResponse.payload) + break + case "redux-action": + UI.store.dispatch(pluginResponse.payload) + break + default: + this.emit("logWarning", "Unexpected plugin type: " + pluginResponse.type) } } diff --git a/browser/src/UI/components/QuickInfo.less b/browser/src/UI/components/QuickInfo.less index 3fbedb419a..b6b63b242a 100644 --- a/browser/src/UI/components/QuickInfo.less +++ b/browser/src/UI/components/QuickInfo.less @@ -4,12 +4,13 @@ transition: all 0.5s; animation-name: appear; animation-duration: 0.5s; + -webkit-user-select: none; + cursor: default; .quickinfo { .box-shadow; background-color: @background-color; - padding: 4px; color: @text-color; text-overflow: ellipsis; overflow: hidden; @@ -17,13 +18,16 @@ .title { width: 100%; white-space: nowrap; - margin: 4px; + margin: 8px; } .documentation { - margin: 4px; + .box-shadow-inset; + padding: 8px; color: @text-color-detail; font-size: @font-size-small; + max-height: 48px; + overflow-y: auto; } .selected { diff --git a/browser/src/UI/components/QuickInfo.tsx b/browser/src/UI/components/QuickInfo.tsx index 6aedfd8b1c..d9043c4b2d 100644 --- a/browser/src/UI/components/QuickInfo.tsx +++ b/browser/src/UI/components/QuickInfo.tsx @@ -50,7 +50,7 @@ export class QuickInfo extends React.Component { const innerStyle = openFromTop ? openFromTopStyle : openFromBottomStyle - return
+ return
{this.props.elements}
@@ -75,6 +75,10 @@ export class QuickInfoTitle extends TextComponent { export class QuickInfoDocumentation extends TextComponent { public render(): JSX.Element { + if (!this.props.text) { + return null + } + const lines = this.props.text.split(os.EOL) const divs = lines.map((l) =>
{l}
) @@ -154,10 +158,12 @@ const mapStateToSignatureHelpProps = (state: IState): IQuickInfoProps => { parameters.splice(i, 0, ) } - let elements = [] + let titleContents = [] .concat(parameters) .concat([]) + let elements = [
{titleContents}
] + const selectedIndex = Math.min(currentItem.parameters.length, state.signatureHelp.argumentIndex) const selectedArgument = currentItem.parameters[selectedIndex] if (selectedArgument && selectedArgument.documentation) {