Skip to content

Commit

Permalink
Fix LayoutCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitabobko committed Oct 29, 2023
1 parent 526ff35 commit c30fcf9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ layout (h_list|v_list|h_accordion|v_accordion|list|accordion|horizontal|vertical

Changes layout of the focused window to the given layout.

If several arguments are supplied then the first layout that describes the currently active is found. The layout specified after
the found one will be applied. If the currently active layout is not in the list, the first layout in the list will be activated.
If several layouts are supplied then finds the first layout that doesn't describe the currently active layout, and applies the
found layout.

`layout tiling` is the only command that makes the focused floating window tiled.

Expand Down
5 changes: 2 additions & 3 deletions src/command/LayoutCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ struct LayoutCommand: Command {
func runWithoutLayout() {
check(Thread.current.isMainThread)
guard let window = focusedWindowOrEffectivelyFocused else { return }
let targetDescription: LayoutDescription = toggleBetween.firstIndex(where: { window.matchesDescription($0) })
.flatMap { toggleBetween.getOrNil(atIndex: $0 + 1) }
.orElse { toggleBetween.first! }
let targetDescription: LayoutDescription = toggleBetween.first(where: { !window.matchesDescription($0) })
?? toggleBetween.first!
if window.matchesDescription(targetDescription) {
return
}
Expand Down

0 comments on commit c30fcf9

Please sign in to comment.