Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update to work with the latest version of brackets.

The className has changed for css properties, and there is now a meta
class for the vendor prefix. Note that with this change, if the cursor
is placed right before the property name, the editor will no longer
appear.

Also fixed a minor bug with a , instead of a ;. JSLint yelled at me as
soon as I opened this up in Brackets. Thank you, JSLint.
  • Loading branch information...
commit 928c4c274eb5711848f30df7d25d1325a01bb8c5 1 parent 7258295
@bemjb bemjb authored
Showing with 9 additions and 10 deletions.
  1. +9 −10 main.js
View
19 main.js
@@ -34,21 +34,20 @@ define(function (require, exports, module) {
function _getTokenListForCurrentDeclaration(hostEditor) {
function _foundBeginning(token) {
- return token.className === "variable";
+ return token.className && token.className.match(/^property/);
}
function _findStart(start) {
var currentToken = hostEditor._codeMirror.getTokenAt(start);
if (_foundBeginning(currentToken)) {
- return { ch: currentToken.start, line: start.line };
- } else if (currentToken.className === null) {
+ return { ch: currentToken.start + 1, line: start.line };
+ } else if (currentToken.className === "meta") {
if (currentToken.end < hostEditor._codeMirror.getLine(start.line).length) {
- // look forward to see if the next token starts our declaration.
- // this covers the case where the user put the cursor right at the beginning
- // of the declaration, since getting the token gives us the token that's right
- // before the current position
+ // if we have a property like -webkit-shape-outside, the -webkit prefix is a
+ // different token type than the property, so if we're on the prefix, we
+ // need to look ahead to find the property.
if (_foundBeginning(hostEditor._codeMirror.getTokenAt({ ch: currentToken.end + 1, line: start.line }))) {
- return { ch: currentToken.end, line: start.line };
+ return { ch: currentToken.end + 1, line: start.line };
}
}
if (currentToken.string.match(/[{};]/)) {
@@ -312,7 +311,7 @@ define(function (require, exports, module) {
var x, y;
if (xy && xy.length === 3) {
- x = _convertUnitsToPixels(xy[1]),
+ x = _convertUnitsToPixels(xy[1]);
y = _convertUnitsToPixels(xy[2]);
if (x !== null && y !== null) {
minMax.addValue(x);
@@ -364,7 +363,7 @@ define(function (require, exports, module) {
case 0: // eat up initial whitespace
if (tokens[i].string.trim()) {
// consume the declaration name
- if (tokens[i].className === "variable" &&
+ if (tokens[i].className && tokens[i].className.match(/^property/) &&
tokens[i].string.match(/^(-\w+-)?shape-(inside|outside)$/)) {
state = 1;
} else {
Please sign in to comment.
Something went wrong with that request. Please try again.