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

Commit b3cffc0

Browse files
committed
Merge pull request #7349 from adobe/pflynn/quickedit-error-strings
Tweak Quick Edit error strings & update docs
2 parents 576da47 + 136ec47 commit b3cffc0

5 files changed

Lines changed: 43 additions & 39 deletions

File tree

src/editor/CSSInlineEditor.js

Lines changed: 18 additions & 18 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") {
@@ -160,9 +160,9 @@ define(function (require, exports, module) {
160160
*
161161
* @param {!Editor} editor
162162
* @param {!{line:Number, ch:Number}} pos
163-
* @return {?$.Promise} synchronously resolved with an InlineWidget, or
164-
* {string} if pos is in tag but not in tag name, class attr, or id attr, or
165-
* null if we're not going to provide anything.
163+
* @return {?$.Promise} synchronously resolved with an InlineWidget; or error
164+
* {string} if pos is in tag but not in tag name, class attr, or id attr; or null if the
165+
* selection isn't even close to a context where we could provide anything.
166166
*/
167167
function htmlToCSSProvider(hostEditor, pos) {
168168

src/editor/EditorManager.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ define(function (require, exports, module) {
164164
* @param {!Editor} editor The host editor
165165
* @param {Array.<{priority:number, provider:function(...)}>} providers
166166
* prioritized list of providers
167-
* @param {string=} defaultErrorMsg Default error message to display if no initial provider found
167+
* @param {string=} defaultErrorMsg Default message to display if no providers return non-null
168168
* @return {$.Promise} a promise that will be resolved when an InlineWidget
169169
* is created or rejected if no inline providers have offered one.
170170
*/
@@ -279,10 +279,10 @@ define(function (require, exports, module) {
279279
* An optional priority parameter is used to give providers with higher priority an opportunity
280280
* to provide an inline editor before providers with lower priority.
281281
*
282-
* @param {function(!Editor, !{line:number, ch:number}):?$.Promise} provider
282+
* @param {function(!Editor, !{line:number, ch:number}):?($.Promise|string)} provider
283283
* @param {number=} priority
284-
* The provider returns a promise that will be resolved with an InlineWidget, or returns null
285-
* to indicate the provider doesn't want to respond to this case.
284+
* The provider returns a promise that will be resolved with an InlineWidget, or returns a string
285+
* indicating why the provider cannot respond to this case (or returns null to indicate no reason).
286286
*/
287287
function registerInlineEditProvider(provider, priority) {
288288
if (priority === undefined) {
@@ -297,10 +297,10 @@ define(function (require, exports, module) {
297297
* An optional priority parameter is used to give providers with higher priority an opportunity
298298
* to provide an inline editor before providers with lower priority.
299299
*
300-
* @param {function(!Editor, !{line:number, ch:number}):?$.Promise} provider
300+
* @param {function(!Editor, !{line:number, ch:number}):?($.Promise|string)} provider
301301
* @param {number=} priority
302-
* The provider returns a promise that will be resolved with an InlineWidget, or returns null
303-
* to indicate the provider doesn't want to respond to this case.
302+
* The provider returns a promise that will be resolved with an InlineWidget, or returns a string
303+
* indicating why the provider cannot respond to this case (or returns null to indicate no reason).
304304
*/
305305
function registerInlineDocsProvider(provider, priority) {
306306
if (priority === undefined) {
@@ -946,7 +946,7 @@ define(function (require, exports, module) {
946946
*
947947
* @param {Array.<{priority:number, provider:function(...)}>} providers
948948
* prioritized list of providers
949-
* @param {string=} errorMsg Error message to display if no initial provider found
949+
* @param {string=} errorMsg Default message to display if no providers return non-null
950950
* @return {!Promise} A promise resolved with true if an inline widget is opened or false
951951
* when closed. Rejected if there is neither an existing widget to close nor a provider
952952
* willing to create a widget (or if no editor is open).

src/extensions/default/JavaScriptQuickEdit/main.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ 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
45-
* @return {functionName: {string}, reason: {string}}
44+
* @param {!{line:number, ch:number}} pos
45+
* @return {functionName: string, reason: string}
4646
*/
4747
function _getFunctionName(hostEditor, pos) {
4848
var token = hostEditor._codeMirror.getTokenAt(pos, true);
@@ -109,7 +109,7 @@ define(function (require, exports, module) {
109109
* @param {!string} functionName
110110
* @return {?$.Promise} synchronously resolved with an InlineWidget, or
111111
* {string} if js other than function is detected at pos, or
112-
* null if we're not going to provide anything.
112+
* null if we're not ready to provide anything.
113113
*/
114114
function _createInlineEditor(hostEditor, functionName) {
115115
// Use Tern jump-to-definition helper, if it's available, to find InlineEditor target.
@@ -186,9 +186,9 @@ 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
191-
* or null if we're not going to provide anything.
191+
* or null if we're not ready to provide anything.
192192
*/
193193
function javaScriptFunctionProvider(hostEditor, pos) {
194194
// Only provide a JavaScript editor when cursor is in JavaScript content

src/nls/root/strings.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,16 @@ define({
180180
"FILE_FILTER_CLIPPED_SUFFIX" : "and {0} more",
181181

182182
// Quick Edit
183-
"ERROR_QUICK_EDIT_PROVIDER_NOT_FOUND" : "No Quick Edit provider found for current cursor position",
184-
"ERROR_CSSQUICKEDIT_CLASSNOTFOUND" : "CSS Quick Edit: place cursor in class name",
185-
"ERROR_CSSQUICKEDIT_IDNOTFOUND" : "CSS Quick Edit: place cursor in id name",
186-
"ERROR_CSSQUICKEDIT_UNSUPPORTEDATTR" : "CSS Quick Edit: place cursor in tag name, class name, or id name",
183+
"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",
185+
"ERROR_CSSQUICKEDIT_CLASSNOTFOUND" : "CSS Quick Edit: incomplete class attribute",
186+
"ERROR_CSSQUICKEDIT_IDNOTFOUND" : "CSS Quick Edit: incomplete 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

190191
// Quick Docs
191-
"ERROR_QUICK_DOCS_PROVIDER_NOT_FOUND" : "No Quick Docs provider found for current cursor position",
192+
"ERROR_QUICK_DOCS_PROVIDER_NOT_FOUND" : "No Quick Docs available for current cursor position",
192193

193194
/**
194195
* ProjectManager

src/project/FileSyncManager.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@
2929
* FileSyncManager is a set of utilities to help track external modifications to the files and folders
3030
* in the currently open project.
3131
*
32-
* Currently, we look for external changes purely by checking file timestamps against the last-sync
33-
* timestamp recorded on Document. Later, we will use actual native directory-watching callbacks
34-
* instead.
32+
* Currently, we detect external changes purely by checking file timestamps against the last-sync
33+
* timestamp recorded on Document. Brackets triggers this check whenever an external change was detected
34+
* by our native file watchers, and on window focus. We recheck all open Documents, but with file caching
35+
* the timestamp check is a fast no-op for everything other than files where a watcher change was just
36+
* notified. If watchers/caching are disabled, we'll essentially check only on window focus, and we'll hit
37+
* the disk to check every open Document's timestamp every time.
3538
*
3639
* FUTURE: Whenever we have a 'project file tree model,' we should manipulate that instead of notifying
3740
* DocumentManager directly. DocumentManager, the tree UI, etc. then all listen to that model for changes.

0 commit comments

Comments
 (0)