Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update IntelliSense for paginate directive: Suggest new keywords skip and hold #429

Merged
merged 2 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- 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))
- Support `paginate: skip` and `paginate: hold` from Marpit framework [v2.5.0](https://github.com/marp-team/marpit/releases/v2.5.0)
- 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))
- Update IntelliSense for `paginate` directive: Suggest new keywords `skip` and `hold` ([#429](https://github.com/marp-team/marp-vscode/pull/429))

### Fixed

Expand Down
13 changes: 12 additions & 1 deletion src/directives/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,18 @@ export const builtinDirectives = [
// Marpit local directives
createDirectiveInfo({
name: 'paginate',
description: 'Show page number on the slide if set `true`.',
description: dedent(`
Control the slide page number.
Use the boolean values \`true\` and \`false\` to control the visibility of the page number on the slide.
You can also manage the page number increment behavior using the additional keywords \`skip\` and \`hold\`.
- \`false\`: Hide the page number. (default)
- \`true\`: Show the page number.
- \`skip\`: Hide the page number and prevent its increment.
- \`hold\`: Show the page number, but prevent increment even on the following page(s).
`),
allowed: directiveAlwaysAllowed,
providedBy: DirectiveProvidedBy.Marpit,
type: DirectiveType.Local,
Expand Down
6 changes: 4 additions & 2 deletions src/language/completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ describe('Auto completions', () => {
})
})

describe('Boolean suggestion', () => {
it('suggests boolean values when the cursor is on paginate directive', async () => {
describe('Paginate directive suggestion', () => {
it('suggests acceptable values for paginate directive when the cursor is on the directive', async () => {
const doc = setDocument('---\nmarp: true\npaginate: \n---')
const list = (await provideCompletionItems()(
doc,
Expand All @@ -294,6 +294,8 @@ describe('Auto completions', () => {
expect(labels).toMatchInlineSnapshot(`
[
"false",
"hold",
"skip",
"true",
]
`)
Expand Down
23 changes: 19 additions & 4 deletions src/language/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class CompletionProvider {
getCompletionList() {
return (
this.completionThemes() ||
this.completionBoolean() ||
this.completionPaginate() ||
this.completionMath() ||
this.completionSizePreset() ||
this.completionBuiltInTransitions() ||
Expand All @@ -144,18 +144,33 @@ class CompletionProvider {
}
}

private completionBoolean() {
private completionPaginate() {
if (this.isCursorOnDirective('paginate', DirectiveType.Local)) {
return new CompletionList([
{
detail: 'Boolean',
detail: 'Keyword for paginate directive',
kind: CompletionItemKind.EnumMember,
label: 'true',
documentation: 'Show the page number.',
},
{
detail: 'Boolean',
detail: 'Keyword for paginate directive',
kind: CompletionItemKind.EnumMember,
label: 'false',
documentation: 'Hide the page number.',
},
{
detail: 'Keyword for paginate directive',
kind: CompletionItemKind.EnumMember,
label: 'skip',
documentation: 'Hide the page number and prevent its increment.',
},
{
detail: 'Keyword for paginate directive',
kind: CompletionItemKind.EnumMember,
label: 'hold',
documentation:
'Show the page number, but prevent increment even on the following page(s).',
},
])
}
Expand Down