From b4e0dad4f975b635f48d35e272016d59ff84ceb1 Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Mon, 7 Apr 2014 16:37:04 -0700 Subject: [PATCH] respond to comments --- src/editor/EditorCommandHandlers.js | 2 +- src/extensions/default/JavaScriptCodeHints/Session.js | 2 +- src/extensions/default/JavaScriptQuickEdit/main.js | 2 +- src/language/CSSUtils.js | 2 +- src/language/HTMLUtils.js | 6 +++--- src/utils/TokenUtils.js | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/editor/EditorCommandHandlers.js b/src/editor/EditorCommandHandlers.js index 5ba7e49b274..5cb11d464c9 100644 --- a/src/editor/EditorCommandHandlers.js +++ b/src/editor/EditorCommandHandlers.js @@ -303,7 +303,7 @@ define(function (require, exports, module) { var result, text, line; // Move the context to the first non-empty token. - if (!ctx.token.type && ctx.token.string.trim().length === 0) { + if (!ctx.token.type && !/\S/.test(ctx.token.string)) { result = TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, ctx); } diff --git a/src/extensions/default/JavaScriptCodeHints/Session.js b/src/extensions/default/JavaScriptCodeHints/Session.js index f8cc9fdcfc6..e8afb72d5c7 100644 --- a/src/extensions/default/JavaScriptCodeHints/Session.js +++ b/src/extensions/default/JavaScriptCodeHints/Session.js @@ -200,7 +200,7 @@ define(function (require, exports, module) { break; } prev = this.getToken(cursor); - } while (prev.string.trim() === ""); + } while (!/\S/.test(prev.string)); return prev; }; diff --git a/src/extensions/default/JavaScriptQuickEdit/main.js b/src/extensions/default/JavaScriptQuickEdit/main.js index 5b0303ea08f..e72446f1e4e 100644 --- a/src/extensions/default/JavaScriptQuickEdit/main.js +++ b/src/extensions/default/JavaScriptQuickEdit/main.js @@ -49,7 +49,7 @@ define(function (require, exports, module) { // If the pos is at the beginning of a name, token will be the // preceding whitespace or dot. In that case, try the next pos. - if (token.string.trim().length === 0 || token.string === ".") { + if (!/\S/.test(token.string) || token.string === ".") { token = hostEditor._codeMirror.getTokenAt({line: pos.line, ch: pos.ch + 1}, true); } diff --git a/src/language/CSSUtils.js b/src/language/CSSUtils.js index 1cfd52868f2..66a99e35195 100644 --- a/src/language/CSSUtils.js +++ b/src/language/CSSUtils.js @@ -1033,7 +1033,7 @@ define(function (require, exports, module) { result.push(entry); } else if (!classOrIdSelector) { // Special case for tag selectors - match "*" as the rightmost character - if (/.*\*\s*$/.test(entry.selector)) { + if (/\*\s*$/.test(entry.selector)) { result.push(entry); } } diff --git a/src/language/HTMLUtils.js b/src/language/HTMLUtils.js index 9c7a0279dc9..4040806ca20 100644 --- a/src/language/HTMLUtils.js +++ b/src/language/HTMLUtils.js @@ -153,7 +153,7 @@ define(function (require, exports, module) { } // If we type the first letter of the next attribute, it comes as an error // token. We need to double check for possible invalidated attributes. - if (forwardCtx.token.string.trim() !== "" && + if (/\S/.test(forwardCtx.token.string) !== "" && forwardCtx.token.string.indexOf("\"") === -1 && forwardCtx.token.string.indexOf("'") === -1 && forwardCtx.token.string.indexOf("=") === -1) { @@ -316,7 +316,7 @@ define(function (require, exports, module) { } //check and see where we are in the tag - if (ctx.token.string.length > 0 && ctx.token.string.trim().length === 0) { + if (ctx.token.string.length > 0 && !/\S/.test(ctx.token.string)) { // token at (i.e. before) pos is whitespace, so test token at next pos // @@ -326,7 +326,7 @@ define(function (require, exports, module) { var testPos = {ch: ctx.pos.ch + 1, line: ctx.pos.line}, testToken = editor._codeMirror.getTokenAt(testPos, true); - if (testToken.string.length > 0 && testToken.string.trim().length > 0 && + if (testToken.string.length > 0 && /\S/.test(testToken.string) && testToken.string.charAt(0) !== ">") { // pos has whitespace before it and non-whitespace after it, so use token after ctx.token = testToken; diff --git a/src/utils/TokenUtils.js b/src/utils/TokenUtils.js index ec12ed726d3..0ee085ccfaa 100644 --- a/src/utils/TokenUtils.js +++ b/src/utils/TokenUtils.js @@ -113,7 +113,7 @@ define(function (require, exports, module) { if (!moveFxn(ctx)) { return false; } - while (!ctx.token.type && ctx.token.string.trim().length === 0) { + while (!ctx.token.type && !/\S/.test(ctx.token.string)) { if (!moveFxn(ctx)) { return false; }