Skip to content

Commit 7b0be23

Browse files
committed
fix(renderer-lua_patterns): Fixed description of some character classes
Closes #2 refactor(renderer-lua_patterns): Changed description text of negated character classes Closes #2
1 parent 0b6cb92 commit 7b0be23

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

lua/patterns/renderers/lua_patterns.lua

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ lua_patterns.tips = {
6060
}, "\n");
6161
end,
6262

63-
character_set = "Matches characters from a set of matches.",
63+
character_set = function (_, item)
64+
if string.match(item.text, "^%[%^") then
65+
return "Matches characters that aren't part of this set.";
66+
else
67+
return "Matches characters that are part of this set.";
68+
end
69+
end,
6470
-- character_set_content = "Set of matches.",
6571
capture_group = "A pattern group to be used for various string operations.",
6672
character_range = "Matches character within the given range.",
@@ -89,9 +95,9 @@ lua_patterns.tips = {
8995
elseif txt == "%P" then
9096
table.insert(_l, '"%P" matches anything that\'s not a punctuation symbol. It\'s equivalent would be: [^a-z].');
9197
elseif txt == "%s" then
92-
table.insert(_l, '"%p" matches all whitespace characters. It\'s equivalent would be: [ \\t\\n\\r].');
98+
table.insert(_l, '"%s" matches all whitespace characters. It\'s equivalent would be: [ \\t\\n\\r].');
9399
elseif txt == "%S" then
94-
table.insert(_l, '"%P" matches anything that\'s not a punctuation symbol. It\'s equivalent would be: [^ \\t\\n\\r].');
100+
table.insert(_l, '"%S" matches anything that\'s not a whitespace character. It\'s equivalent would be: [^ \\t\\n\\r].');
95101
elseif txt == "%u" then
96102
table.insert(_l, '"%u" matches all uppercase letters. It\'s equivalent would be: [A-Z].');
97103
elseif txt == "%U" then
@@ -105,9 +111,9 @@ lua_patterns.tips = {
105111
elseif txt == "%X" then
106112
table.insert(_l, '"%X" matches anything that\'s not an hexadecimal character. It\'s equivalent would be: [^a-fA-F0-9].');
107113
elseif txt == "%z" then
108-
table.insert(_l, '"%x" matches the null byte. It\'s equivalent would be: [\\0].');
114+
table.insert(_l, '"%x" matches the null character. It\'s equivalent would be: [\\0].');
109115
elseif txt == "%Z" then
110-
table.insert(_l, '"%Z" matches anything that\'s not a null byte. It\'s equivalent would be: [^\\0].');
116+
table.insert(_l, '"%Z" matches anything that\'s not a null character. It\'s equivalent would be: [^\\0].');
111117
else
112118
table.remove(_l, 2);
113119
end

lua/patterns/spec.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,13 @@ spec.default = {
228228
},
229229

230230
character_set = {
231-
text = "󱉓 Character set",
231+
text = function (_, item)
232+
if string.match(item.text, "^%[%^") then
233+
return "󱋍 Negated character set";
234+
else
235+
return "󱉓 Character set";
236+
end
237+
end,
232238
show_tip = on_current,
233239

234240
tip_hl = "PatternsPalette3Bg",

0 commit comments

Comments
 (0)