From 01278f51f2e44828bce6c448ca49f3c94af17d69 Mon Sep 17 00:00:00 2001 From: Shubham Yadav Date: Thu, 11 Apr 2019 19:49:38 +0530 Subject: [PATCH 1/6] Code Hint Desc first cut --- src/editor/CodeHintList.js | 43 +++++++++++-- src/editor/CodeHintManager.js | 33 ++++++---- .../default/PhpTooling/CodeHintsProvider.js | 62 +++++++++++++------ .../styles/default_provider_style.css | 42 +++++++++++++ 4 files changed, 146 insertions(+), 34 deletions(-) diff --git a/src/editor/CodeHintList.js b/src/editor/CodeHintList.js index 964e1ed447c..31c8537d5ff 100644 --- a/src/editor/CodeHintList.js +++ b/src/editor/CodeHintList.js @@ -121,6 +121,14 @@ define(function (require, exports, module) { .append(""); this._keydownHook = this._keydownHook.bind(this); + + var self = this; + this.$hintMenu.find("ul.dropdown-menu")[0].onscroll = function () { + var ext = self.$hintMenu.find(".hint-selection-ext"); + var highlight = self.$hintMenu.find("a.highlight"); + ext.css("top", highlight.position().top); + ext.css("height", highlight[0].getBoundingClientRect().height); + }; } /** @@ -142,6 +150,7 @@ define(function (require, exports, module) { } this.selectedIndex = index; + var ext = this.$hintMenu.find("ul.dropdown-menu").parent().find(".hint-selection-ext"); // Highlight the new selected item, if necessary if (this.selectedIndex !== -1) { @@ -150,10 +159,15 @@ define(function (require, exports, module) { $item.find("a").addClass("highlight"); ViewUtils.scrollElementIntoView($view, $item, false); + var highlight = $item.find("a.highlight"); + ext.css("top", highlight.position().top); + ext.css("height", highlight[0].getBoundingClientRect().height); if (this.handleHighlight) { - this.handleHighlight($item.find("a")); + this.handleHighlight($item.find("a"), this.$hintMenu.find("#codehint-desc")); } + } else { + ext.css("height", 0); } }; @@ -191,6 +205,7 @@ define(function (require, exports, module) { this.hints = hintObj.hints; this.hints.handleWideResults = hintObj.handleWideResults; + this.enableDescription = hintObj.enableDescription; // if there is no match, assume name is already a formatted jQuery // object; otherwise, use match to format name for display. @@ -264,7 +279,17 @@ define(function (require, exports, module) { // attach to DOM $parent.append($ul); - + $parent.find(".hint-selection-ext-track").remove(); + $("
").appendTo($parent); + + // If a a description field requested attach one + if (this.enableDescription) { + // Remove the desc element first to ensure DOM order + $parent.find("#codehint-desc").remove(); + $parent.append(""); + $ul.addClass("withDesc"); + $parent.find(".hint-selection-ext-track").addClass("withDesc"); + } this._setSelectedIndex(selectInitial ? 0 : -1); } }; @@ -283,7 +308,9 @@ define(function (require, exports, module) { textHeight = this.editor.getTextHeight(), $window = $(window), $menuWindow = this.$hintMenu.children("ul"), - menuHeight = $menuWindow.outerHeight(); + $descElement = this.$hintMenu.find("#codehint-desc"), + descOverhang = $descElement.length === 1 ? $descElement.height() : 0, + menuHeight = $menuWindow.outerHeight() + descOverhang; // TODO Ty: factor out menu repositioning logic so code hints and Context menus share code // adjust positioning so menu is not clipped off bottom or right @@ -304,6 +331,12 @@ define(function (require, exports, module) { availableWidth = menuWidth + Math.abs(rightOverhang); } + var descOffset = this.$hintMenu.find("ul.dropdown-menu")[0].getBoundingClientRect().height; + if (descOffset === 0) { + descOffset = menuHeight - descOverhang; + } + this.$hintMenu.find(".hint-selection-ext-track").css("height", descOffset - 1); + return {left: posLeft, top: posTop, width: availableWidth}; }; @@ -400,7 +433,7 @@ define(function (require, exports, module) { if (event.keyCode === KeyEvent.DOM_VK_ESCAPE) { event.stopImmediatePropagation(); this.handleClose(); - + return false; } else if (event.shiftKey && (event.keyCode === KeyEvent.DOM_VK_UP || @@ -513,7 +546,7 @@ define(function (require, exports, module) { if (this.hints.length) { var hintPos = this._calcHintListLocation(); this.$hintMenu.css({"left": hintPos.left, "top": hintPos.top, - "width": hintPos.width + "px"}); + "width": hintPos.width + "px"}); } }; /** diff --git a/src/editor/CodeHintManager.js b/src/editor/CodeHintManager.js index 8a2cdf28e69..566a07c73fc 100644 --- a/src/editor/CodeHintManager.js +++ b/src/editor/CodeHintManager.js @@ -239,7 +239,7 @@ define(function (require, exports, module) { CodeHintList = require("editor/CodeHintList").CodeHintList, PreferencesManager = require("preferences/PreferencesManager"); - var hintProviders = { "all" : [] }, + var hintProviders = { "all": [] }, lastChar = null, sessionProvider = null, sessionEditor = null, @@ -289,7 +289,7 @@ define(function (require, exports, module) { */ function registerHintProvider(providerInfo, languageIds, priority) { var providerObj = { provider: providerInfo, - priority: priority || 0 }; + priority: priority || 0 }; if (languageIds.indexOf("all") !== -1) { // Ignore anything else in languageIds and just register for every language. This includes @@ -401,10 +401,10 @@ define(function (require, exports, module) { (hintList.isOpen() || (deferredHints && deferredHints.state() === "pending"))) { return true; - } else { - // the editor has changed - _endSession(); } + // the editor has changed + _endSession(); + } return false; } @@ -507,10 +507,21 @@ define(function (require, exports, module) { sessionEditor = editor; hintList = new CodeHintList(sessionEditor, insertHintOnTab, maxCodeHints); - hintList.onHighlight(function ($hint) { - // If the current hint provider listening for hint item highlight change - if (sessionProvider.onHighlight) { - sessionProvider.onHighlight($hint); + hintList.onHighlight(function ($hint, $hintDescContainer) { + if (hintList.enableDescription && $hintDescContainer && $hintDescContainer.length) { + // If the current hint provider listening for hint item highlight change + if (sessionProvider.onHighlight) { + sessionProvider.onHighlight($hint, $hintDescContainer); + } + + // Update the hint description + if (sessionProvider.updateHintDescription) { + sessionProvider.updateHintDescription($hint, $hintDescContainer); + } + } else { + if (sessionProvider.onHighlight) { + sessionProvider.onHighlight($hint); + } } }); hintList.onSelect(function (hint) { @@ -565,7 +576,7 @@ define(function (require, exports, module) { function _handleKeyupEvent(jqEvent, editor, event) { keyDownEditor = editor; if (_inSession(editor)) { - if (event.keyCode === KeyEvent.DOM_VK_HOME || + if (event.keyCode === KeyEvent.DOM_VK_HOME || event.keyCode === KeyEvent.DOM_VK_END) { _endSession(); } else if (event.keyCode === KeyEvent.DOM_VK_LEFT || @@ -714,7 +725,7 @@ define(function (require, exports, module) { activeEditorChangeHandler(null, EditorManager.getActiveEditor(), null); EditorManager.on("activeEditorChange", activeEditorChangeHandler); - + // Dismiss code hints before executing any command other than showing code hints since the command // may make the current hinting session irrevalent after execution. // For example, when the user hits Ctrl+K to open Quick Doc, it is diff --git a/src/extensions/default/PhpTooling/CodeHintsProvider.js b/src/extensions/default/PhpTooling/CodeHintsProvider.js index 937f26476eb..1775436409f 100644 --- a/src/extensions/default/PhpTooling/CodeHintsProvider.js +++ b/src/extensions/default/PhpTooling/CodeHintsProvider.js @@ -36,7 +36,19 @@ define(function (require, exports, module) { preferPrefixMatches: true }); - var phpSuperGlobalVariables = JSON.parse(require("text!phpGlobals.json")); + var phpSuperGlobalVariables = JSON.parse(require("text!phpGlobals.json")), + hintType = { + "2": "Method", + "3": "Function", + "4": "Constructor", + "6": "Variable", + "7": "Class", + "8": "Interface", + "9": "Module", + "10": "Property", + "14": "Keyword", + "21": "Constant" + }; function CodeHintsProvider(client) { this.defaultCodeHintProviders = new DefaultProviders.CodeHintsProvider(client); @@ -44,22 +56,7 @@ define(function (require, exports, module) { function formatTypeDataForToken($hintObj, token) { $hintObj.addClass('brackets-hints-with-type-details'); - if (token.detail) { - if (token.detail.trim() !== '?') { - if (token.detail.length < 30) { - $('' + token.detail.split('->').join(':').toString().trim() + '').appendTo($hintObj).addClass("brackets-hints-type-details"); - } - $('' + token.detail.split('->').join(':').toString().trim() + '').appendTo($hintObj).addClass("hint-description"); - } - } else { - if (token.keyword) { - $('keyword').appendTo($hintObj).addClass("brackets-hints-keyword"); - } - } - if (token.documentation) { - $hintObj.attr('title', token.documentation); - $('').text(token.documentation.trim()).appendTo($hintObj).addClass("hint-doc"); - } + $hintObj.data('completionItem', token); } function filterWithQueryAndMatcher(hints, query) { @@ -102,6 +99,7 @@ define(function (require, exports, module) { self.query = context.token.string.slice(0, context.pos.ch - context.token.start); if (msgObj) { var res = msgObj.items || []; + console.log("results:", res); // There is a bug in Php Language Server, Php Language Server does not provide superGlobals // Variables as completion. so these variables are being explicity put in response objects // below code should be removed if php server fix this bug. @@ -143,7 +141,9 @@ define(function (require, exports, module) { } $deferredHints.resolve({ - "hints": hints + "hints": hints, + "selectInitial": true, + "enableDescription": true }); }).fail(function () { $deferredHints.reject(); @@ -156,5 +156,31 @@ define(function (require, exports, module) { return this.defaultCodeHintProviders.insertHint($hint); }; + CodeHintsProvider.prototype.updateHintDescription = function ($hint, $hintDescContainer) { + var $hintObj = $hint.find('.brackets-hints-with-type-details'), + token = $hintObj.data('completionItem'), + $desc = $('
'); + + $hintDescContainer.empty(); + if(!token) { + return; + } + + if (token.detail) { + if (token.detail.trim() !== '?') { + $('
' + token.detail.split('->').join(':').toString().trim() + '
').appendTo($desc).addClass("desc-detail"); + } + } else { + if (hintType[token.kind]) { + $('
' + hintType[token.kind] + '
').appendTo($desc).addClass("desc-detail"); + } + } + if (token.documentation) { + $('
').html(token.documentation.trim()).appendTo($desc).addClass("desc-doc"); + } + + $hintDescContainer.append($desc); + }; + exports.CodeHintsProvider = CodeHintsProvider; }); diff --git a/src/languageTools/styles/default_provider_style.css b/src/languageTools/styles/default_provider_style.css index 5090330b28c..695a1dff47f 100644 --- a/src/languageTools/styles/default_provider_style.css +++ b/src/languageTools/styles/default_provider_style.css @@ -132,3 +132,45 @@ span.brackets-hints-with-type-details { .dark .hint-description { color: #ccc; } + +#codehint-desc { + background: #e6e6e6; + position: relative; + width: 100%; + box-sizing: border-box; + float: left; + top: 34px; + border-radius: 1px !important; + border-top-left-radius: 0px !important; + border-top-right-radius: 0px !important; + overflow-x: hidden; + min-height: 30px; + max-height: 120px !important +} + +.dark #codehint-desc { + background: #2c2c2c; +} + +.desc-detail { + padding: 5px 15px 5px 15px; + color: #1473e6; + font-weight:bold; + font-size: 1.2em; +} + +.dark .desc-detail { + color: #46a0f5; + line-height: inherit; +} + +.desc-doc { + padding: 5px 15px 5px 15px; + color: #424242; + font-size: 1.1em; + white-space: pre-wrap; +} + +.dark .desc-doc { + color: #b1b1b1 +} \ No newline at end of file From a77dc07d7c19add8f3ff74f3766bd19d85c33032 Mon Sep 17 00:00:00 2001 From: Shubham Yadav Date: Thu, 11 Apr 2019 20:16:11 +0530 Subject: [PATCH 2/6] Remove extra code --- src/editor/CodeHintList.js | 28 ++++++------------- src/editor/CodeHintManager.js | 14 +++++----- .../default/PhpTooling/CodeHintsProvider.js | 6 ++-- 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/src/editor/CodeHintList.js b/src/editor/CodeHintList.js index 31c8537d5ff..ae28fafc193 100644 --- a/src/editor/CodeHintList.js +++ b/src/editor/CodeHintList.js @@ -121,14 +121,6 @@ define(function (require, exports, module) { .append(""); this._keydownHook = this._keydownHook.bind(this); - - var self = this; - this.$hintMenu.find("ul.dropdown-menu")[0].onscroll = function () { - var ext = self.$hintMenu.find(".hint-selection-ext"); - var highlight = self.$hintMenu.find("a.highlight"); - ext.css("top", highlight.position().top); - ext.css("height", highlight[0].getBoundingClientRect().height); - }; } /** @@ -150,7 +142,6 @@ define(function (require, exports, module) { } this.selectedIndex = index; - var ext = this.$hintMenu.find("ul.dropdown-menu").parent().find(".hint-selection-ext"); // Highlight the new selected item, if necessary if (this.selectedIndex !== -1) { @@ -159,15 +150,10 @@ define(function (require, exports, module) { $item.find("a").addClass("highlight"); ViewUtils.scrollElementIntoView($view, $item, false); - var highlight = $item.find("a.highlight"); - ext.css("top", highlight.position().top); - ext.css("height", highlight[0].getBoundingClientRect().height); if (this.handleHighlight) { this.handleHighlight($item.find("a"), this.$hintMenu.find("#codehint-desc")); } - } else { - ext.css("height", 0); } }; @@ -279,8 +265,9 @@ define(function (require, exports, module) { // attach to DOM $parent.append($ul); - $parent.find(".hint-selection-ext-track").remove(); - $("
").appendTo($parent); + + $parent.find(".hint-list-offset").remove(); + $("
").appendTo($parent); // If a a description field requested attach one if (this.enableDescription) { @@ -288,7 +275,7 @@ define(function (require, exports, module) { $parent.find("#codehint-desc").remove(); $parent.append(""); $ul.addClass("withDesc"); - $parent.find(".hint-selection-ext-track").addClass("withDesc"); + $parent.find(".hint-list-offset").addClass("withDesc"); } this._setSelectedIndex(selectInitial ? 0 : -1); } @@ -331,11 +318,12 @@ define(function (require, exports, module) { availableWidth = menuWidth + Math.abs(rightOverhang); } + //Creating the offset element for hint description element var descOffset = this.$hintMenu.find("ul.dropdown-menu")[0].getBoundingClientRect().height; if (descOffset === 0) { descOffset = menuHeight - descOverhang; } - this.$hintMenu.find(".hint-selection-ext-track").css("height", descOffset - 1); + this.$hintMenu.find(".hint-list-offset").css("height", descOffset - 1); return {left: posLeft, top: posTop, width: availableWidth}; }; @@ -433,7 +421,7 @@ define(function (require, exports, module) { if (event.keyCode === KeyEvent.DOM_VK_ESCAPE) { event.stopImmediatePropagation(); this.handleClose(); - + return false; } else if (event.shiftKey && (event.keyCode === KeyEvent.DOM_VK_UP || @@ -546,7 +534,7 @@ define(function (require, exports, module) { if (this.hints.length) { var hintPos = this._calcHintListLocation(); this.$hintMenu.css({"left": hintPos.left, "top": hintPos.top, - "width": hintPos.width + "px"}); + "width": hintPos.width + "px"}); } }; /** diff --git a/src/editor/CodeHintManager.js b/src/editor/CodeHintManager.js index 566a07c73fc..e99fd568108 100644 --- a/src/editor/CodeHintManager.js +++ b/src/editor/CodeHintManager.js @@ -239,7 +239,7 @@ define(function (require, exports, module) { CodeHintList = require("editor/CodeHintList").CodeHintList, PreferencesManager = require("preferences/PreferencesManager"); - var hintProviders = { "all": [] }, + var hintProviders = { "all" : [] }, lastChar = null, sessionProvider = null, sessionEditor = null, @@ -289,7 +289,7 @@ define(function (require, exports, module) { */ function registerHintProvider(providerInfo, languageIds, priority) { var providerObj = { provider: providerInfo, - priority: priority || 0 }; + priority: priority || 0 }; if (languageIds.indexOf("all") !== -1) { // Ignore anything else in languageIds and just register for every language. This includes @@ -401,10 +401,10 @@ define(function (require, exports, module) { (hintList.isOpen() || (deferredHints && deferredHints.state() === "pending"))) { return true; - } + } else { // the editor has changed - _endSession(); - + _endSession(); + } } return false; } @@ -576,7 +576,7 @@ define(function (require, exports, module) { function _handleKeyupEvent(jqEvent, editor, event) { keyDownEditor = editor; if (_inSession(editor)) { - if (event.keyCode === KeyEvent.DOM_VK_HOME || + if (event.keyCode === KeyEvent.DOM_VK_HOME || event.keyCode === KeyEvent.DOM_VK_END) { _endSession(); } else if (event.keyCode === KeyEvent.DOM_VK_LEFT || @@ -725,7 +725,7 @@ define(function (require, exports, module) { activeEditorChangeHandler(null, EditorManager.getActiveEditor(), null); EditorManager.on("activeEditorChange", activeEditorChangeHandler); - + // Dismiss code hints before executing any command other than showing code hints since the command // may make the current hinting session irrevalent after execution. // For example, when the user hits Ctrl+K to open Quick Doc, it is diff --git a/src/extensions/default/PhpTooling/CodeHintsProvider.js b/src/extensions/default/PhpTooling/CodeHintsProvider.js index 1775436409f..912fa37cab5 100644 --- a/src/extensions/default/PhpTooling/CodeHintsProvider.js +++ b/src/extensions/default/PhpTooling/CodeHintsProvider.js @@ -54,7 +54,7 @@ define(function (require, exports, module) { this.defaultCodeHintProviders = new DefaultProviders.CodeHintsProvider(client); } - function formatTypeDataForToken($hintObj, token) { + function setStyleAndCacheToken($hintObj, token) { $hintObj.addClass('brackets-hints-with-type-details'); $hintObj.data('completionItem', token); } @@ -99,7 +99,6 @@ define(function (require, exports, module) { self.query = context.token.string.slice(0, context.pos.ch - context.token.start); if (msgObj) { var res = msgObj.items || []; - console.log("results:", res); // There is a bug in Php Language Server, Php Language Server does not provide superGlobals // Variables as completion. so these variables are being explicity put in response objects // below code should be removed if php server fix this bug. @@ -135,14 +134,13 @@ define(function (require, exports, module) { } $fHint.data("token", element); - formatTypeDataForToken($fHint, element); + setStyleAndCacheToken($fHint, element); hints.push($fHint); }); } $deferredHints.resolve({ "hints": hints, - "selectInitial": true, "enableDescription": true }); }).fail(function () { From 02d8d93199a190a8c139aa13eeb1b26924ae36d6 Mon Sep 17 00:00:00 2001 From: Shubham Yadav Date: Thu, 11 Apr 2019 20:19:46 +0530 Subject: [PATCH 3/6] Fixing Lint Issues --- src/editor/CodeHintList.js | 6 +++--- src/editor/CodeHintManager.js | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/editor/CodeHintList.js b/src/editor/CodeHintList.js index ae28fafc193..ef8cb5283cd 100644 --- a/src/editor/CodeHintList.js +++ b/src/editor/CodeHintList.js @@ -265,7 +265,7 @@ define(function (require, exports, module) { // attach to DOM $parent.append($ul); - + $parent.find(".hint-list-offset").remove(); $("
").appendTo($parent); @@ -421,7 +421,7 @@ define(function (require, exports, module) { if (event.keyCode === KeyEvent.DOM_VK_ESCAPE) { event.stopImmediatePropagation(); this.handleClose(); - + return false; } else if (event.shiftKey && (event.keyCode === KeyEvent.DOM_VK_UP || @@ -534,7 +534,7 @@ define(function (require, exports, module) { if (this.hints.length) { var hintPos = this._calcHintListLocation(); this.$hintMenu.css({"left": hintPos.left, "top": hintPos.top, - "width": hintPos.width + "px"}); + "width": hintPos.width + "px"}); } }; /** diff --git a/src/editor/CodeHintManager.js b/src/editor/CodeHintManager.js index e99fd568108..7d9c45cee3d 100644 --- a/src/editor/CodeHintManager.js +++ b/src/editor/CodeHintManager.js @@ -239,7 +239,7 @@ define(function (require, exports, module) { CodeHintList = require("editor/CodeHintList").CodeHintList, PreferencesManager = require("preferences/PreferencesManager"); - var hintProviders = { "all" : [] }, + var hintProviders = { "all": [] }, lastChar = null, sessionProvider = null, sessionEditor = null, @@ -289,7 +289,7 @@ define(function (require, exports, module) { */ function registerHintProvider(providerInfo, languageIds, priority) { var providerObj = { provider: providerInfo, - priority: priority || 0 }; + priority: priority || 0 }; if (languageIds.indexOf("all") !== -1) { // Ignore anything else in languageIds and just register for every language. This includes @@ -401,10 +401,10 @@ define(function (require, exports, module) { (hintList.isOpen() || (deferredHints && deferredHints.state() === "pending"))) { return true; - } else { - // the editor has changed - _endSession(); } + // the editor has changed + _endSession(); + } return false; } @@ -513,7 +513,7 @@ define(function (require, exports, module) { if (sessionProvider.onHighlight) { sessionProvider.onHighlight($hint, $hintDescContainer); } - + // Update the hint description if (sessionProvider.updateHintDescription) { sessionProvider.updateHintDescription($hint, $hintDescContainer); @@ -576,7 +576,7 @@ define(function (require, exports, module) { function _handleKeyupEvent(jqEvent, editor, event) { keyDownEditor = editor; if (_inSession(editor)) { - if (event.keyCode === KeyEvent.DOM_VK_HOME || + if (event.keyCode === KeyEvent.DOM_VK_HOME || event.keyCode === KeyEvent.DOM_VK_END) { _endSession(); } else if (event.keyCode === KeyEvent.DOM_VK_LEFT || @@ -725,7 +725,7 @@ define(function (require, exports, module) { activeEditorChangeHandler(null, EditorManager.getActiveEditor(), null); EditorManager.on("activeEditorChange", activeEditorChangeHandler); - + // Dismiss code hints before executing any command other than showing code hints since the command // may make the current hinting session irrevalent after execution. // For example, when the user hits Ctrl+K to open Quick Doc, it is From db4dc9561e29d05682e96cc8499bf53b16b8f88b Mon Sep 17 00:00:00 2001 From: Shubham Yadav Date: Thu, 11 Apr 2019 20:41:58 +0530 Subject: [PATCH 4/6] Undo ESLINT Fixes --- src/editor/CodeHintList.js | 4 ++-- src/editor/CodeHintManager.js | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/editor/CodeHintList.js b/src/editor/CodeHintList.js index ef8cb5283cd..5a132281d75 100644 --- a/src/editor/CodeHintList.js +++ b/src/editor/CodeHintList.js @@ -421,7 +421,7 @@ define(function (require, exports, module) { if (event.keyCode === KeyEvent.DOM_VK_ESCAPE) { event.stopImmediatePropagation(); this.handleClose(); - + return false; } else if (event.shiftKey && (event.keyCode === KeyEvent.DOM_VK_UP || @@ -534,7 +534,7 @@ define(function (require, exports, module) { if (this.hints.length) { var hintPos = this._calcHintListLocation(); this.$hintMenu.css({"left": hintPos.left, "top": hintPos.top, - "width": hintPos.width + "px"}); + "width": hintPos.width + "px"}); } }; /** diff --git a/src/editor/CodeHintManager.js b/src/editor/CodeHintManager.js index 7d9c45cee3d..925ffcb61ec 100644 --- a/src/editor/CodeHintManager.js +++ b/src/editor/CodeHintManager.js @@ -239,7 +239,7 @@ define(function (require, exports, module) { CodeHintList = require("editor/CodeHintList").CodeHintList, PreferencesManager = require("preferences/PreferencesManager"); - var hintProviders = { "all": [] }, + var hintProviders = { "all" : [] }, lastChar = null, sessionProvider = null, sessionEditor = null, @@ -289,7 +289,7 @@ define(function (require, exports, module) { */ function registerHintProvider(providerInfo, languageIds, priority) { var providerObj = { provider: providerInfo, - priority: priority || 0 }; + priority: priority || 0 }; if (languageIds.indexOf("all") !== -1) { // Ignore anything else in languageIds and just register for every language. This includes @@ -401,10 +401,10 @@ define(function (require, exports, module) { (hintList.isOpen() || (deferredHints && deferredHints.state() === "pending"))) { return true; - } + } else { // the editor has changed - _endSession(); - + _endSession(); + } } return false; } @@ -576,7 +576,7 @@ define(function (require, exports, module) { function _handleKeyupEvent(jqEvent, editor, event) { keyDownEditor = editor; if (_inSession(editor)) { - if (event.keyCode === KeyEvent.DOM_VK_HOME || + if (event.keyCode === KeyEvent.DOM_VK_HOME || event.keyCode === KeyEvent.DOM_VK_END) { _endSession(); } else if (event.keyCode === KeyEvent.DOM_VK_LEFT || @@ -725,7 +725,7 @@ define(function (require, exports, module) { activeEditorChangeHandler(null, EditorManager.getActiveEditor(), null); EditorManager.on("activeEditorChange", activeEditorChangeHandler); - + // Dismiss code hints before executing any command other than showing code hints since the command // may make the current hinting session irrevalent after execution. // For example, when the user hits Ctrl+K to open Quick Doc, it is From 51c1323c0ed7d9ae863bb1487dc43ca4a9adde2e Mon Sep 17 00:00:00 2001 From: Shubham Yadav Date: Fri, 12 Apr 2019 09:58:31 +0530 Subject: [PATCH 5/6] Fix CSS Reflow issue --- src/extensions/default/PhpTooling/CodeHintsProvider.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/extensions/default/PhpTooling/CodeHintsProvider.js b/src/extensions/default/PhpTooling/CodeHintsProvider.js index 912fa37cab5..653449792f4 100644 --- a/src/extensions/default/PhpTooling/CodeHintsProvider.js +++ b/src/extensions/default/PhpTooling/CodeHintsProvider.js @@ -159,8 +159,8 @@ define(function (require, exports, module) { token = $hintObj.data('completionItem'), $desc = $('
'); - $hintDescContainer.empty(); if(!token) { + $hintDescContainer.empty(); return; } @@ -177,6 +177,8 @@ define(function (require, exports, module) { $('
').html(token.documentation.trim()).appendTo($desc).addClass("desc-doc"); } + //To ensure CSS reflow doesn't cause a flicker. + $hintDescContainer.empty(); $hintDescContainer.append($desc); }; From 45e081eaa9f03445a1e90466eb4698366445a5e5 Mon Sep 17 00:00:00 2001 From: Shubham Yadav Date: Sat, 13 Apr 2019 11:31:06 +0530 Subject: [PATCH 6/6] Moving styles to brackets core --- .../default/PhpTooling/CodeHintsProvider.js | 6 +-- .../styles/default_provider_style.css | 42 ------------------- src/styles/brackets_core_ui_variables.less | 10 ++++- src/styles/brackets_patterns_override.less | 42 +++++++++++++++++++ 4 files changed, 54 insertions(+), 46 deletions(-) diff --git a/src/extensions/default/PhpTooling/CodeHintsProvider.js b/src/extensions/default/PhpTooling/CodeHintsProvider.js index 3bd2d624e10..3f54d82f2e1 100644 --- a/src/extensions/default/PhpTooling/CodeHintsProvider.js +++ b/src/extensions/default/PhpTooling/CodeHintsProvider.js @@ -177,15 +177,15 @@ define(function (require, exports, module) { if (token.detail) { if (token.detail.trim() !== '?') { - $('
' + token.detail.split('->').join(':').toString().trim() + '
').appendTo($desc).addClass("desc-detail"); + $('
' + token.detail.split('->').join(':').toString().trim() + '
').appendTo($desc).addClass("codehint-desc-type-details"); } } else { if (hintType[token.kind]) { - $('
' + hintType[token.kind] + '
').appendTo($desc).addClass("desc-detail"); + $('
' + hintType[token.kind] + '
').appendTo($desc).addClass("codehint-desc-type-details"); } } if (token.documentation) { - $('
').html(token.documentation.trim()).appendTo($desc).addClass("desc-doc"); + $('
').html(token.documentation.trim()).appendTo($desc).addClass("codehint-desc-documentation"); } //To ensure CSS reflow doesn't cause a flicker. diff --git a/src/languageTools/styles/default_provider_style.css b/src/languageTools/styles/default_provider_style.css index 695a1dff47f..5090330b28c 100644 --- a/src/languageTools/styles/default_provider_style.css +++ b/src/languageTools/styles/default_provider_style.css @@ -132,45 +132,3 @@ span.brackets-hints-with-type-details { .dark .hint-description { color: #ccc; } - -#codehint-desc { - background: #e6e6e6; - position: relative; - width: 100%; - box-sizing: border-box; - float: left; - top: 34px; - border-radius: 1px !important; - border-top-left-radius: 0px !important; - border-top-right-radius: 0px !important; - overflow-x: hidden; - min-height: 30px; - max-height: 120px !important -} - -.dark #codehint-desc { - background: #2c2c2c; -} - -.desc-detail { - padding: 5px 15px 5px 15px; - color: #1473e6; - font-weight:bold; - font-size: 1.2em; -} - -.dark .desc-detail { - color: #46a0f5; - line-height: inherit; -} - -.desc-doc { - padding: 5px 15px 5px 15px; - color: #424242; - font-size: 1.1em; - white-space: pre-wrap; -} - -.dark .desc-doc { - color: #b1b1b1 -} \ No newline at end of file diff --git a/src/styles/brackets_core_ui_variables.less b/src/styles/brackets_core_ui_variables.less index 3824aa242b2..f6290ce0c0f 100644 --- a/src/styles/brackets_core_ui_variables.less +++ b/src/styles/brackets_core_ui_variables.less @@ -124,7 +124,10 @@ @button-icon: "images/find-replace-sprites.svg"; @jstree-sprite: url("images/jsTreeSprites.svg") !important; - +// Codehint description +@bc-codehint-desc: #e6e6e6; +@bc-codehint-desc-type-details: #1473e6; +@bc-codehint-desc-documentation:#424242; /* Dark Core UI variables -----------------------------------------------------------------------------*/ @@ -213,3 +216,8 @@ // images @dark-button-icon: "images/find-replace-sprites-dark.svg"; @dark-jstree-sprite: url("images/jsTreeSprites-dark.svg") !important; + +// Codehint description +@dark-bc-codehint-desc: #2c2c2c; +@dark-bc-codehint-desc-type-details: #46a0f5; +@dark-bc-codehint-desc-documentation:#b1b1b1; diff --git a/src/styles/brackets_patterns_override.less b/src/styles/brackets_patterns_override.less index 44c2879a7a6..e1de2ba3902 100644 --- a/src/styles/brackets_patterns_override.less +++ b/src/styles/brackets_patterns_override.less @@ -584,6 +584,48 @@ a:focus { transition: right 167ms, left 167ms; } +#codehint-desc { + background: @bc-codehint-desc; + position: relative; + width: 100%; + box-sizing: border-box; + float: left; + top: 34px; + border-radius: 1px !important; + border-top-left-radius: 0px !important; + border-top-right-radius: 0px !important; + overflow-x: hidden; + min-height: 30px; + max-height: 120px !important; + + .dark & { + background: @dark-bc-codehint-desc; + } +} + +.codehint-desc-type-details { + padding: 5px 15px 5px 15px; + color: @bc-codehint-desc-type-details; + font-weight: bold; + font-size: 1.2em; + line-height: inherit; + + .dark & { + color: @dark-bc-codehint-desc-type-details; + } +} + +.codehint-desc-documentation { + padding: 5px 15px 5px 15px; + color: @bc-codehint-desc-documentation; + font-size: 1.1em; + white-space: pre-wrap; + + .dark & { + color: @dark-bc-codehint-desc-documentation; + } +} + #context-menu-bar { margin: 0; }