vscode-plantuml
vscode-plantuml copied to clipboard
Only preview first page when using the newpage command
Hello,
I am using PlantUML extension v2.14.3 on vscode 1.54.1 on Windows 10. When I want to create a multipage diagram like in issue #341, it only renders the first page. I mean: I press Alt+D to preview the diagram, the bottom buttons show well that there are 3 pages but when I switch from one page to the other, the rendered diagram stays the same i.e. the one of the first page.
Any idea why?
@startuml
A->B: Hello
newpage
B->C: Hello
newpage
C->A: Hello
A->A: back
@enduml
cannot reproduce in mac
This code reproduces the problem on my machine. Using just newpage (without the procedure) is ok.
@startuml PKI
!$one_page = 0
!procedure $newpage()
!if $one_page == 0
newpage
!endif
!endprocedure
a->b
$newpage()
b->a
@enduml
Running the jar from the command line it works like expected.
I believe the problem lies in how pages are counted.
in /src/plantuml/diagram/diagram.ts:
public get pageCount(): number {
if (this._pageCount !== undefined) {
return this._pageCount;
}
this._pageCount = 1;
if (this.lines) {
let regNewPage = /^\s*newpage\b/i;
for (let text of this.lines) {
if (regNewPage.test(text)) this._pageCount++;
}
}
return this._pageCount;
}