From 0b71a76b34d02bb63ed022b2bc9f9c2b47660736 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Sun, 6 Nov 2022 19:19:40 +0100 Subject: [PATCH] fix(generator): utils.is_empty --- src/awesomewm.d.tl/generator/snippets.tl | 10 ++++++++-- src/awesomewm.d.tl/utils.tl | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/awesomewm.d.tl/generator/snippets.tl b/src/awesomewm.d.tl/generator/snippets.tl index daeff11..7eb86df 100644 --- a/src/awesomewm.d.tl/generator/snippets.tl +++ b/src/awesomewm.d.tl/generator/snippets.tl @@ -69,8 +69,14 @@ function snippets.render_records_from_Parameters(items: List 0 end):concat("\n") - end):filter(function(p: string): boolean return #p > 0 end):concat("\n") + end):filter( + function (s: string): boolean + return not utils.is_empty(s) + end):concat("\n") + end):filter( + function (s: string): boolean + return not utils.is_empty(s) + end):concat("\n") end function snippets.render_record_functions(items: List): string diff --git a/src/awesomewm.d.tl/utils.tl b/src/awesomewm.d.tl/utils.tl index f4debbb..ff97a48 100644 --- a/src/awesomewm.d.tl/utils.tl +++ b/src/awesomewm.d.tl/utils.tl @@ -43,6 +43,10 @@ function utils.capitalize(s: string): string return (s:gsub("^%l", string.upper)) end +function utils.is_empty(s: string): boolean + return s == nil or s == "" +end + -- At some point, we should probably write a wrapper to make penlight's function work with pcalls. function utils.do_or_fail(func: function(...: any): (T | nil, string), ...: any): T local logger = require "logger"