Fix hover over 'cron:' token
This commit is contained in:
@@ -91,6 +91,16 @@ jobs:
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("on a cron identifier", async () => {
|
||||||
|
const input = `on:
|
||||||
|
schedule:
|
||||||
|
- c|ron: '0 0 * * *'
|
||||||
|
`;
|
||||||
|
const result = await hover(...getPositionFromCursor(input));
|
||||||
|
expect(result).not.toBeUndefined();
|
||||||
|
expect(result?.contents).toEqual("");
|
||||||
|
});
|
||||||
|
|
||||||
it("on an invalid cron schedule", async () => {
|
it("on an invalid cron schedule", async () => {
|
||||||
const input = `on:
|
const input = `on:
|
||||||
schedule:
|
schedule:
|
||||||
|
|||||||
@@ -33,8 +33,9 @@ function getHover(tokenResult: TokenResult): Hover | null {
|
|||||||
if (!token) {
|
if (!token) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (tokenResult.parent && isCronMapping(tokenResult.parent) && isString(token)) {
|
if (tokenResult.parent && isCronMappingValue(tokenResult)) {
|
||||||
let description = getSentence((token as StringToken).value);
|
const tokenValue = (token as StringToken).value
|
||||||
|
let description = getSentence(tokenValue);
|
||||||
if (description) {
|
if (description) {
|
||||||
description +=
|
description +=
|
||||||
"\n\nActions schedules run at most every 5 minutes." +
|
"\n\nActions schedules run at most every 5 minutes." +
|
||||||
@@ -72,6 +73,8 @@ function getHover(tokenResult: TokenResult): Hover | null {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isCronMapping(token: TemplateToken): boolean {
|
function isCronMappingValue(tokenResult: TokenResult): boolean {
|
||||||
return token.definition?.key === "cron-mapping";
|
return tokenResult.parent?.definition?.key === "cron-mapping" &&
|
||||||
|
(tokenResult.token as StringToken).value !== "cron" &&
|
||||||
|
isString(tokenResult.token!);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user