Skip to content

Respect tabWidth for useTabs and script/style line width - #671

Merged
Shinigami92 merged 2 commits into
prettier:mainfrom
bminer:fix/use-tabs-line-width
Oct 1, 2026
Merged

Shinigami92 merged 2 commits into
prettier:mainfrom
bminer:fix/use-tabs-line-width

Conversation

@bminer

@bminer bminer commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #268

bminer and others added 2 commits September 29, 2026 12:22
When `useTabs` was enabled, each tab was counted as a single column when
computing the current line length after an indent, outdent or newline.
Deeply nested lines were therefore considered shorter than they are and
attributes were not wrapped.

Count every indentation level as `pugTabWidth` columns regardless of
whether tabs or spaces are used.

Fixes prettier#268

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Content of `script` and `style` blocks was formatted with the code
interpolation options, which use a `printWidth` of 9000, so long lines
were never wrapped. Format it with `printWidth` minus the indentation
width of the block instead, which also respects `useTabs` and `tabWidth`

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bminer
bminer requested a review from Shinigami92 as a code owner September 29, 2026 16:42
@Shinigami92 Shinigami92 added the type: bug Functionality that does not work as intended/expected label Sep 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 93.7% (🎯 90%)
⬆️ +0.01%
1042 / 1112
🟢 Statements 93.58% (🎯 90%)
🟰 ±0%
1051 / 1123
🟢 Functions 97.95% (🎯 90%)
⬆️ +0.01%
144 / 147
🔴 Branches 88.15% (🎯 90%)
🟰 ±0%
685 / 777
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/printer.ts 94.03%
⬆️ +0.01%
89.15%
🟰 ±0%
100%
🟰 ±0%
94.24%
⬆️ +0.01%
337, 374, 537-539, 551-560, 565-576, 625-678, 717, 803-806, 1154, 1248, 1276, 1285, 1576, 1623, 1842, 1881, 2031-2036, 2080-2084
Unchanged Files
src/doctype-shortcut-registry.ts 100% 100% 100% 100%
src/index.ts 86.66% 100% 71.42% 86.66% 79-85
src/logger.ts 82.14% 42.85% 91.66% 82.14% 37-44, 93, 153-155
src/prettier.d.ts 100% 100% 100% 100%
src/options/common.ts 100% 100% 100% 100%
src/options/constants.ts 100% 100% 100% 100%
src/options/converge.ts 100% 82.6% 100% 100%
src/options/index.ts 100% 100% 100% 100%
src/options/pug-attribute-separator.ts 75% 100% 100% 75% 52-54
src/options/pug-class-location.ts 100% 100% 100% 100%
src/options/pug-class-notation.ts 100% 100% 100% 100%
src/options/pug-closing-bracket-indent-depth.ts 100% 100% 100% 100%
src/options/pug-comment-preserve-spaces.ts 100% 100% 100% 100%
src/options/pug-explicit-div.ts 100% 100% 100% 100%
src/options/pug-framework.ts 100% 100% 100% 100%
src/options/pug-id-notation.ts 100% 100% 100% 100%
src/options/pug-preserve-attribute-brackets.ts 100% 100% 100% 100%
src/options/pug-preserve-whitespace.ts 100% 100% 100% 100%
src/options/pug-single-file-component-indentation.ts 100% 100% 100% 100%
src/options/pug-wrap-attributes.ts 100% 100% 100% 100%
src/options/types.ts 100% 100% 100% 100%
src/options/attribute-sorting/index.ts 100% 100% 100% 100%
src/options/attribute-sorting/utils.ts 96% 91.66% 100% 95.83% 82, 94
src/options/empty-attributes/index.ts 100% 100% 100% 100%
src/options/empty-attributes/types.ts 100% 100% 100% 100%
src/options/empty-attributes/utils.ts 100% 100% 100% 100%
src/utils/angular.ts 100% 100% 100% 100%
src/utils/common.ts 89.7% 86.76% 100% 88.88% 19, 27, 56, 258, 262, 269-272, 331
src/utils/script-mime-types.ts 86.66% 75% 100% 86.66% 42, 49
src/utils/svelte.ts 100% 100% 100% 100%
src/utils/vue.ts 100% 100% 100% 100%
Generated in workflow #1628 for commit b9b0451 by the Vitest Coverage Report Action

@Shinigami92 Shinigami92 changed the title Fix/use tabs line width Respect tabWidth for useTabs and script/style line width Oct 1, 2026
@Shinigami92
Shinigami92 added this pull request to the merge queue Oct 1, 2026
Merged via the queue into prettier:main with commit e1aff43 Oct 1, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Functionality that does not work as intended/expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Incorrect wrapping when useTabs: true, assumes tab is 0 width

2 participants