Support notes in rule lists.

This commit is contained in:
FelisCatus 2017-09-20 11:20:14 -07:00
parent a536ff5d98
commit b1c261c39c

View File

@ -95,6 +95,8 @@ module.exports = exports =
ruleList += eol ruleList += eol
specialLineStart = exports['Switchy'].specialLineStart + '+' specialLineStart = exports['Switchy'].specialLineStart + '+'
for rule in rules for rule in rules
if rule.note
ruleList += '@note ' + rule.note + eol
line = Conditions.str(rule.condition) line = Conditions.str(rule.condition)
if useExclusive and rule.profileName == defaultProfileName if useExclusive and rule.profileName == defaultProfileName
line = '!' + line line = '!' + line
@ -185,6 +187,7 @@ module.exports = exports =
rulesWithDefaultProfile = [] rulesWithDefaultProfile = []
withResult = false withResult = false
exclusiveProfile = null exclusiveProfile = null
noteForNextRule = null
lno = 0 lno = 0
for line in text.split(/\n|\r/) for line in text.split(/\n|\r/)
lno++ lno++
@ -205,6 +208,8 @@ module.exports = exports =
feature = line.toUpperCase() feature = line.toUpperCase()
if feature == 'RESULT' or feature == 'RESULTS' if feature == 'RESULT' or feature == 'RESULTS'
withResult = true withResult = true
when 'NOTE'
noteForNextRule = line
continue continue
source = null source = null
@ -243,6 +248,9 @@ module.exports = exports =
condition: cond condition: cond
profileName: profile profileName: profile
source: if includeSource then source ? line source: if includeSource then source ? line
if noteForNextRule?
rule.note = noteForNextRule
noteForNextRule = null
rules.push(rule) rules.push(rule)
if not profile if not profile
rulesWithDefaultProfile.push(rule) rulesWithDefaultProfile.push(rule)