Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 4dc3df0

Browse files
committed
Dynamic hint menu height implementations to show only 8 lines of info at any font size
1 parent 013c8c5 commit 4dc3df0

File tree

2 files changed

+48
-6
lines changed

2 files changed

+48
-6
lines changed

src/extensions/default/JavaScriptCodeHints/styles/brackets-js-hints.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ span.brackets-js-hints-with-type-details {
149149
color: #d4d4d4;
150150
word-wrap: break-word;
151151
white-space: normal;
152-
width:300px;
153152
box-sizing: border-box;
154153
}
155154

@@ -163,12 +162,15 @@ span.brackets-js-hints-with-type-details {
163162
color: grey;
164163
word-wrap: break-word;
165164
white-space: normal;
166-
width: 300px;
167165
box-sizing: border-box;
168166
float: left;
169167
clear: left;
170-
max-height: 3em;
168+
max-height: 2em;
171169
overflow: hidden;
170+
text-overflow: ellipsis;
171+
line-height: 1em;
172+
-webkit-line-clamp: 2;
173+
-webkit-box-orient: vertical;
172174
}
173175

174176
.dark .jshint-jsdoc {
@@ -219,7 +221,7 @@ span.brackets-js-hints-with-type-details {
219221
}
220222

221223
.highlight .jshint-jsdoc {
222-
display: block;
224+
display: -webkit-box;
223225
}
224226

225227
.dark .brackets-js-hints-type-details {

src/view/ViewCommandHandlers.js

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ define(function (require, exports, module) {
7878
* @type {string}
7979
*/
8080
var DYNAMIC_CODEHINT_WITH_TYPE_STYLE_ID = "codehint-with-type-dynamic-width";
81+
82+
/**
83+
* @const
84+
* @type {string}
85+
*/
86+
var DYNAMIC_CODEHINT_HEIGHT_STYLE_ID = "codehint-dynamic-height";
8187

8288
/**
8389
* @const
@@ -124,6 +130,30 @@ define(function (require, exports, module) {
124130
* @type {number}
125131
*/
126132
var DEFAULT_TYPED_HINT_SPAN_WIDTH = 300;
133+
134+
/**
135+
* @const
136+
* @private
137+
* The default hint menu max-height
138+
* @type {number}
139+
*/
140+
var DEFAULT_HINT_MENU_HEIGHT = 160;
141+
142+
/**
143+
* @const
144+
* @private
145+
* The default hint menu item line height offset
146+
* @type {number}
147+
*/
148+
var DEFAULT_HINT_MENU_LINE_HEIGHT_OFFSET = 7;
149+
150+
/**
151+
* @const
152+
* @private
153+
* The default number of visible menu items
154+
* @type {number}
155+
*/
156+
var DEFAULT_VISIBLE_HINT_MENU_ITEMS_COUNT = 8;
127157

128158
/**
129159
* @private
@@ -155,7 +185,7 @@ define(function (require, exports, module) {
155185
_removeDynamicProperty(propertyID);
156186
$("head").append($style);
157187
}
158-
188+
159189
/**
160190
* @private
161191
* Removes the styles used to update the font size
@@ -164,16 +194,18 @@ define(function (require, exports, module) {
164194
_removeDynamicProperty(DYNAMIC_FONT_STYLE_ID);
165195
_removeDynamicProperty(DYNAMIC_CODEHINT_FONT_STYLE_ID);
166196
_removeDynamicProperty(DYNAMIC_CODEHINT_WITH_TYPE_STYLE_ID);
197+
_removeDynamicProperty(DYNAMIC_CODEHINT_HEIGHT_STYLE_ID);
167198
}
168199

169200
/**
170201
* @private
171202
* Adds a new embeded style top sync code-hint font size with codeview font size
203+
* @param {string} fontSize A string with the font size and the size unit
172204
*/
173205
function _addDynamicFontSizeForCodeHints(fontSize) {
174206
var styleStr = "";
175207
styleStr = styleStr + StringUtils.format("{0}: {1} {2};", "font-size", fontSize, " !important");
176-
styleStr = styleStr + StringUtils.format("{0}: {1} {2};", "line-height", (parseInt(fontSize, 10) + 2) + fontSize.replace(parseInt(fontSize, 10), ""), " !important");
208+
styleStr = styleStr + StringUtils.format("{0}: {1} {2};", "line-height", (parseInt(fontSize, 10) + 5) + fontSize.replace(parseInt(fontSize, 10), ""), " !important");
177209

178210
_addDynamicProperty(DYNAMIC_CODEHINT_FONT_STYLE_ID, {
179211
propName: "font-size",
@@ -190,6 +222,14 @@ define(function (require, exports, module) {
190222
ruleName: "span.brackets-js-hints-with-type-details",
191223
ruleText: ""
192224
});
225+
226+
_addDynamicProperty(DYNAMIC_CODEHINT_HEIGHT_STYLE_ID, {
227+
propName: "max-height",
228+
propValue: DEFAULT_VISIBLE_HINT_MENU_ITEMS_COUNT * (parseInt(fontSize, 10) + DEFAULT_HINT_MENU_LINE_HEIGHT_OFFSET) + "px",
229+
priorityFlag: true,
230+
ruleName: ".codehint-menu .dropdown-menu",
231+
ruleText: ""
232+
});
193233
}
194234

195235
/**

0 commit comments

Comments
 (0)