Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fixed a panic when hanging a floor division (`//`) expression, or formatting one with comments around the operator, when only the `luau` feature is enabled ([#1190](https://github.com/JohnnyMorganz/StyLua/issues/1190))

## [2.6.0] - 2026-10-10

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/formatters/trivia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ define_update_trivia!(BinOp, |this, leading, trailing| {
TwoEqual,
#[cfg(feature = "lua53")]
Ampersand,
#[cfg(feature = "lua53")]
#[cfg(any(feature = "luau", feature = "lua53"))]
DoubleSlash,
#[cfg(feature = "lua53")]
DoubleLessThan,
Expand Down
6 changes: 4 additions & 2 deletions src/formatters/trivia_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,10 @@ impl GetLeadingTrivia for BinOp {
| BinOp::TildeEqual(token)
| BinOp::TwoDots(token)
| BinOp::TwoEqual(token) => GetLeadingTrivia::leading_trivia(token),
#[cfg(any(feature = "luau", feature = "lua53"))]
BinOp::DoubleSlash(token) => GetLeadingTrivia::leading_trivia(token),
#[cfg(feature = "lua53")]
BinOp::Ampersand(token)
| BinOp::DoubleSlash(token)
| BinOp::DoubleLessThan(token)
| BinOp::Pipe(token)
| BinOp::DoubleGreaterThan(token)
Expand Down Expand Up @@ -575,9 +576,10 @@ impl GetTrailingTrivia for BinOp {
| BinOp::TildeEqual(token)
| BinOp::TwoDots(token)
| BinOp::TwoEqual(token) => GetTrailingTrivia::trailing_trivia(token),
#[cfg(any(feature = "luau", feature = "lua53"))]
BinOp::DoubleSlash(token) => GetTrailingTrivia::trailing_trivia(token),
#[cfg(feature = "lua53")]
BinOp::Ampersand(token)
| BinOp::DoubleSlash(token)
| BinOp::DoubleLessThan(token)
| BinOp::Pipe(token)
| BinOp::DoubleGreaterThan(token)
Expand Down
5 changes: 5 additions & 0 deletions tests/inputs-luau/floor-division.lua
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
local x = 1 // 2
local column = (mousePosition.X - inventoryFrame.AbsolutePosition.X + scrollingFrame.CanvasPosition.X) // (SLOT_SIZE + SLOT_PADDING)
local y = a -- comment
// b
local z = a // -- comment
b
8 changes: 7 additions & 1 deletion tests/snapshots/tests__luau@floor-division.lua.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
---
source: tests/tests.rs
expression: format(&contents)
expression: "format(&contents, LuaVersion::Luau)"
input_file: tests/inputs-luau/floor-division.lua
---
local x = 1 // 2
local column = (mousePosition.X - inventoryFrame.AbsolutePosition.X + scrollingFrame.CanvasPosition.X)
// (SLOT_SIZE + SLOT_PADDING)
local y = a -- comment
// b
local z = a -- comment
// b