Skip to content

Commit

Permalink
api/focus: Fix the layer name parsing, again
Browse files Browse the repository at this point in the history
The previous change made Chrysalis not error out when there were no layer names
present, but it also broke the name parsing when there were. With this change,
we handle both cases appropriately.

Signed-off-by: Gergely Nagy <[email protected]>
  • Loading branch information
algernon committed Jul 23, 2022
1 parent d45e9c4 commit 6295a2e
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/api/focus/layernames.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,11 @@ export default class LayerNames {
const data = await s.request("keymap.layerNames");
if (!data) return { storageSize: 0, names: [] };

const storageSize = data
.split(/\n/)
.map((x) => x.split(/^(\d+) /).slice(1))
.pop()[1]
.split(/=/)
.pop();
const names = data.split(/\n/).map((x) => x.split(/^(\d+) /).slice(1));
const storageSize = names.pop()[1].split(/=/).pop();
return {
storageSize: parseInt(storageSize),
names: data.map((x) => x[1]),
names: names.map((x) => x[1]),
};
}

Expand Down

0 comments on commit 6295a2e

Please sign in to comment.