typstfmt icon indicating copy to clipboard operation
typstfmt copied to clipboard

[bug] New indent is added to ignored code block on each run (of formatting)

Open Andrew15-5 opened this issue 1 year ago • 10 comments

Before formatting
#let template(doc) = {
  //typstfmt::off
  show figure.where(kind: table): it => align(center)[
    #it.body
  ]
  //typstfmt::on

  // END ======================================================================
  doc
}

#let template(doc) = [
  //typstfmt::off
  #show figure.where(kind: table): it => align(center)[
    #it.body
  ]
  //typstfmt::on

  // END ======================================================================
  #doc
]

#let template(doc) = [
//typstfmt::off
#show figure.where(kind: table): it => align(center)[
  #it.body
]
//typstfmt::on

// END ======================================================================
#doc
]
After 1st run
#let template(doc) = {
  //typstfmt::off
  show figure.where(kind: table): it => align(center)[
      #it.body
    ]
    //typstfmt::on

  // END ======================================================================
  doc
}

#let template(doc) = [
//typstfmt::off
  #show figure.where(kind: table): it => align(center)[
    #it.body
  ]
  //typstfmt::on

// END ======================================================================
#doc
]

#let template(doc) = [
//typstfmt::off
#show figure.where(kind: table): it => align(center)[
  #it.body
]
//typstfmt::on

// END ======================================================================
#doc
]
After 10th run
#let template(doc) = {
  //typstfmt::off
  show figure.where(kind: table): it => align(center)[
                        #it.body
                      ]
                      //typstfmt::on

  // END ======================================================================
  doc
}

#let template(doc) = [
//typstfmt::off
  #show figure.where(kind: table): it => align(center)[
    #it.body
  ]
  //typstfmt::on

// END ======================================================================
#doc
]

#let template(doc) = [
//typstfmt::off
#show figure.where(kind: table): it => align(center)[
  #it.body
]
//typstfmt::on

// END ======================================================================
#doc
]

Smaller examples:

#let template(doc) = {
  //typstfmt::off
  let a = ""
  //typstfmt::on
  // END ======================================================================
  doc
}
#let template(doc) = {
  let a = ""
  //typstfmt::off
  //typstfmt::on
  // END ======================================================================
  doc
}

Config:

ident_space = 2
max_line_length = 80
experimental_args_breaking_consecutive = false

Version: https://github.com/astrale-sharp/typstfmt/commit/578d39fb304020d0c26118e4eeab272868c9d525

Andrew15-5 avatar Aug 26 '23 17:08 Andrew15-5