Skip to content

Commit 7d84876

Browse files
srguiwizmarijnh
authored andcommitted
[xml-hint addon] Allow attribute values function to return a Promise
1 parent ac4aaa0 commit 7d84876

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

addon/hint/xml-hint.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,14 @@
101101
}
102102
replaceToken = true;
103103
}
104-
for (var i = 0; i < atValues.length; ++i) if (!prefix || matches(atValues[i], prefix, matchInMiddle))
105-
result.push(quote + atValues[i] + quote);
104+
function returnHintsFromAtValues(atValues) {
105+
if (atValues)
106+
for (var i = 0; i < atValues.length; ++i) if (!prefix || matches(atValues[i], prefix, matchInMiddle))
107+
result.push(quote + atValues[i] + quote);
108+
return returnHints();
109+
}
110+
if (atValues && atValues.then) return atValues.then(returnHintsFromAtValues);
111+
return returnHintsFromAtValues(atValues);
106112
} else { // An attribute name
107113
if (token.type == "attribute") {
108114
prefix = token.string;
@@ -112,11 +118,14 @@
112118
result.push(attr);
113119
}
114120
}
115-
return {
116-
list: result,
117-
from: replaceToken ? Pos(cur.line, tagStart == null ? token.start : tagStart) : cur,
118-
to: replaceToken ? Pos(cur.line, token.end) : cur
119-
};
121+
function returnHints() {
122+
return {
123+
list: result,
124+
from: replaceToken ? Pos(cur.line, tagStart == null ? token.start : tagStart) : cur,
125+
to: replaceToken ? Pos(cur.line, token.end) : cur
126+
};
127+
}
128+
return returnHints();
120129
}
121130

122131
CodeMirror.registerHelper("hint", "xml", getHints);

0 commit comments

Comments
 (0)