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

Commit 6beff76

Browse files
committed
Further improve Quck Edit error strings. Break out a new separate case for
cursor pos being ambiguous between two class names. Fix some more JSDoc typos found in code review.
1 parent 4be2a8a commit 6beff76

3 files changed

Lines changed: 19 additions & 18 deletions

File tree

src/editor/CSSInlineEditor.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,21 @@ define(function (require, exports, module) {
7575
// class="error-dialog modal hide"
7676
// and the insertion point is inside "modal", we want ".modal"
7777
var attributeValue = tagInfo.attr.value;
78-
var startIndex = attributeValue.substr(0, tagInfo.position.offset).lastIndexOf(" ");
79-
var endIndex = attributeValue.indexOf(" ", tagInfo.position.offset);
80-
selectorName = "." +
81-
attributeValue.substring(
82-
startIndex === -1 ? 0 : startIndex + 1,
83-
endIndex === -1 ? attributeValue.length : endIndex
84-
);
85-
86-
// If the insertion point is surrounded by space, selectorName is "."
87-
// Check for that here
88-
if (selectorName === ".") {
89-
selectorName = "";
90-
}
91-
92-
if (selectorName === "") {
78+
if (attributeValue.trim()) {
79+
var startIndex = attributeValue.substr(0, tagInfo.position.offset).lastIndexOf(" ");
80+
var endIndex = attributeValue.indexOf(" ", tagInfo.position.offset);
81+
selectorName = "." +
82+
attributeValue.substring(
83+
startIndex === -1 ? 0 : startIndex + 1,
84+
endIndex === -1 ? attributeValue.length : endIndex
85+
);
86+
87+
// If the insertion point is surrounded by space between two classnames, selectorName is "."
88+
if (selectorName === ".") {
89+
selectorName = "";
90+
reason = Strings.ERROR_CSSQUICKEDIT_BETWEENCLASSES;
91+
}
92+
} else {
9393
reason = Strings.ERROR_CSSQUICKEDIT_CLASSNOTFOUND;
9494
}
9595
} else if (tagInfo.attr.name === "id") {

src/extensions/default/JavaScriptQuickEdit/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ define(function (require, exports, module) {
4141
* Return the token string that is at the specified position.
4242
*
4343
* @param hostEditor {!Editor} editor
44-
* @param {!{line:Number, ch:Number}} pos
44+
* @param {!{line:number, ch:number}} pos
4545
* @return {functionName: string, reason: string}
4646
*/
4747
function _getFunctionName(hostEditor, pos) {
@@ -186,7 +186,7 @@ define(function (require, exports, module) {
186186
* and shows (one/all of them) in an inline editor.
187187
*
188188
* @param {!Editor} editor
189-
* @param {!{line:Number, ch:Number}} pos
189+
* @param {!{line:number, ch:number}} pos
190190
* @return {$.Promise} a promise that will be resolved with an InlineWidget
191191
* or null if we're not going to provide anything.
192192
*/

src/nls/root/strings.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,10 @@ define({
181181

182182
// Quick Edit
183183
"ERROR_QUICK_EDIT_PROVIDER_NOT_FOUND" : "No Quick Edit available for current cursor position",
184+
"ERROR_CSSQUICKEDIT_BETWEENCLASSES" : "CSS Quick Edit: place cursor on a single class name",
184185
"ERROR_CSSQUICKEDIT_CLASSNOTFOUND" : "CSS Quick Edit: incomplete class attribute",
185186
"ERROR_CSSQUICKEDIT_IDNOTFOUND" : "CSS Quick Edit: incomplete id attribute",
186-
"ERROR_CSSQUICKEDIT_UNSUPPORTEDATTR" : "CSS Quick Edit: place cursor in tag name, class attribute, or id attribute",
187+
"ERROR_CSSQUICKEDIT_UNSUPPORTEDATTR" : "CSS Quick Edit: place cursor in tag, class, or id",
187188
"ERROR_TIMINGQUICKEDIT_INVALIDSYNTAX" : "CSS Timing Function Quick Edit: invalid syntax",
188189
"ERROR_JSQUICKEDIT_FUNCTIONNOTFOUND" : "JS Quick Edit: place cursor in function name",
189190

0 commit comments

Comments
 (0)