Skip to content

Commit c9b25ad

Browse files
authored
Merge pull request #429 from marp-team/update-paginate-directive-intellisense
Update IntelliSense for `paginate` directive: Suggest new keywords `skip` and `hold`
2 parents 1a53c6d + 5634eb1 commit c9b25ad

File tree

4 files changed

+36
-7
lines changed

4 files changed

+36
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Upgrade Marp Core to [v3.8.0](https://github.com/marp-team/marp-core/releases/tag/v3.8.0) ([#427](https://github.com/marp-team/marp-vscode/pull/427))
88
- Support `paginate: skip` and `paginate: hold` from Marpit framework [v2.5.0](https://github.com/marp-team/marpit/releases/v2.5.0)
99
- Upgrade Marp CLI to [v3.2.0](https://github.com/marp-team/marp-cli/releases/tag/v3.2.0) ([#427](https://github.com/marp-team/marp-vscode/pull/427))
10+
- Update IntelliSense for `paginate` directive: Suggest new keywords `skip` and `hold` ([#429](https://github.com/marp-team/marp-vscode/pull/429))
1011

1112
### Fixed
1213

src/directives/definitions.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,18 @@ export const builtinDirectives = [
143143
// Marpit local directives
144144
createDirectiveInfo({
145145
name: 'paginate',
146-
description: 'Show page number on the slide if set `true`.',
146+
description: dedent(`
147+
Control the slide page number.
148+
149+
Use the boolean values \`true\` and \`false\` to control the visibility of the page number on the slide.
150+
151+
You can also manage the page number increment behavior using the additional keywords \`skip\` and \`hold\`.
152+
153+
- \`false\`: Hide the page number. (default)
154+
- \`true\`: Show the page number.
155+
- \`skip\`: Hide the page number and prevent its increment.
156+
- \`hold\`: Show the page number, but prevent increment even on the following page(s).
157+
`),
147158
allowed: directiveAlwaysAllowed,
148159
providedBy: DirectiveProvidedBy.Marpit,
149160
type: DirectiveType.Local,

src/language/completions.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ describe('Auto completions', () => {
279279
})
280280
})
281281

282-
describe('Boolean suggestion', () => {
283-
it('suggests boolean values when the cursor is on paginate directive', async () => {
282+
describe('Paginate directive suggestion', () => {
283+
it('suggests acceptable values for paginate directive when the cursor is on the directive', async () => {
284284
const doc = setDocument('---\nmarp: true\npaginate: \n---')
285285
const list = (await provideCompletionItems()(
286286
doc,
@@ -294,6 +294,8 @@ describe('Auto completions', () => {
294294
expect(labels).toMatchInlineSnapshot(`
295295
[
296296
"false",
297+
"hold",
298+
"skip",
297299
"true",
298300
]
299301
`)

src/language/completions.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class CompletionProvider {
117117
getCompletionList() {
118118
return (
119119
this.completionThemes() ||
120-
this.completionBoolean() ||
120+
this.completionPaginate() ||
121121
this.completionMath() ||
122122
this.completionSizePreset() ||
123123
this.completionBuiltInTransitions() ||
@@ -144,18 +144,33 @@ class CompletionProvider {
144144
}
145145
}
146146

147-
private completionBoolean() {
147+
private completionPaginate() {
148148
if (this.isCursorOnDirective('paginate', DirectiveType.Local)) {
149149
return new CompletionList([
150150
{
151-
detail: 'Boolean',
151+
detail: 'Keyword for paginate directive',
152152
kind: CompletionItemKind.EnumMember,
153153
label: 'true',
154+
documentation: 'Show the page number.',
154155
},
155156
{
156-
detail: 'Boolean',
157+
detail: 'Keyword for paginate directive',
157158
kind: CompletionItemKind.EnumMember,
158159
label: 'false',
160+
documentation: 'Hide the page number.',
161+
},
162+
{
163+
detail: 'Keyword for paginate directive',
164+
kind: CompletionItemKind.EnumMember,
165+
label: 'skip',
166+
documentation: 'Hide the page number and prevent its increment.',
167+
},
168+
{
169+
detail: 'Keyword for paginate directive',
170+
kind: CompletionItemKind.EnumMember,
171+
label: 'hold',
172+
documentation:
173+
'Show the page number, but prevent increment even on the following page(s).',
159174
},
160175
])
161176
}

0 commit comments

Comments
 (0)