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

The 'break' keyword causes problems when formatting

Open exceedsystem opened this issue 3 years ago • 1 comments

First of all, thanks for the very useful extension.

Here is the problem. When using the 'break' keyword in a loop, the indentation is broken after formatting.

Before formatting:

@startuml
start
repeat
    if (Abort?) then (yes)
      :Cleanup;
      break
    endif
    :Do Something;
repeat while (Completed?) is (no)
stop
@enduml

After formatting:

@startuml
start
repeat
  if (Abort?) then (yes)
    :Cleanup;
    break
    endif
    :Do Something;
  repeat while (Completed?) is (no)
  stop
  @enduml

Best regards.

exceedsystem avatar Feb 18 '22 14:02 exceedsystem

I have checked the source code 'FormatRules.ts' a bit.

This problem is caused that the "break" keyword in PlantUML is a block keyword in sequence diagrams, but not in activity diagrams.

However, it does not seem easy to solve this problem in the keyword-based formatter, because the same keywords need to be considered as different contexts.

exceedsystem avatar Jul 19 '22 03:07 exceedsystem