vscode-plantuml icon indicating copy to clipboard operation
vscode-plantuml copied to clipboard

Only preview first page when using the newpage command

Open boubou191911 opened this issue 3 years ago • 2 comments

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

boubou191911 avatar Mar 15 '21 07:03 boubou191911

image image image cannot reproduce in mac

qjebbs avatar Mar 29 '21 03:03 qjebbs

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;
    }

hawk78 avatar Sep 29 '22 06:09 hawk78