Skip to content

Commit

Permalink
Fix: layout name being overwritten causing search to fail
Browse files Browse the repository at this point in the history
  • Loading branch information
natemaia committed Apr 14, 2024
1 parent c797e40 commit b847279
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ int cmdlayout(char **argv)
return 1;
}

for (uint32_t i = 0; layouts[i].name; i++) {
if (!strcmp(layouts[i].name, *argv)) {
for (uint32_t i = 0; layouts[i].command; i++) {
if (!strcmp(layouts[i].command, *argv)) {
if (&layouts[i] != setws->layout) {
setws->layout = &layouts[i];
needsrefresh = lytchange = 1;
Expand Down
26 changes: 15 additions & 11 deletions src/config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,22 @@ Cmd wincmds[] = {
};

Layout layouts[] = {
/* command, function, implements_resize, invert_split_direction */
{"tile", ltile, 1, 0}, /* first is default */
{"rtile", rtile, 1, 0},
{"mono", mono, 0, 0},
{"grid", grid, 0, 0},
{"spiral", spiral, 1, 0},
{"dwindle", dwindle, 1, 0},
{"none", NULL, 1, 0}, /* NULL layout function is floating */
{"tstack", tstack, 1, 1},
{"dyntile", dyntile, 1, 0},
/* we keep two copies of the string for the command and name
* this allows us to update the display name without changing the command
* see in dyntile above where the current layout is modified */

/* name, command, function, implements_resize, invert_split_direction */
{"tile", "tile", ltile, 1, 0}, /* first is default */
{"rtile", "rtile", rtile, 1, 0},
{"mono", "mono", mono, 0, 0},
{"grid", "grid", grid, 0, 0},
{"spiral", "spiral", spiral, 1, 0},
{"dwindle", "dwindle", dwindle, 1, 0},
{"none", "none", NULL, 1, 0}, /* NULL layout function is floating */
{"tstack", "tstack", tstack, 1, 1},
{"dyntile", "dyntile", dyntile, 1, 0},
/* don't add below the terminating null */
{NULL, NULL, 0, 0}
{NULL, NULL, NULL, 0, 0}
};

WsCmd wscmds[] = {
Expand Down
1 change: 1 addition & 0 deletions src/dk.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ typedef struct WsCmd {

typedef struct Layout {
const char *name;
const char *command;
int (*func)(Workspace *);
int implements_resize;
int invert_split_direction;
Expand Down

0 comments on commit b847279

Please sign in to comment.