updated to v1.8.1

This commit is contained in:
Dan Remollino
2023-03-25 19:48:36 -04:00
parent 43859dd6cd
commit db583f08ef
3 changed files with 13 additions and 9 deletions

View File

@ -1,3 +1,6 @@
## Version 1.8.1
- fixed duplicate text on every output line when indented selection was preceded by non-whitespace characters
## Version 1.8
- fixed missing font links
- added BDF and C64 font sets

View File

@ -16,8 +16,5 @@ FIGlet Text requires [FIGlet](http://www.figlet.org) to be installed locally. Th
# How to Use FIGlet Text
FIGlet Text will add a 'Convert Selection to FIGlet' menu item to the Editor menu. Make one or more selections in the editor and run the command.
# Known Issues
- selected text with non-whitespace characters preceding the selection will output the text on each line
# Planned Features
- borders

View File

@ -92,9 +92,16 @@ nova.commands.register('figletTextEditor', editor => {
let selectedRanges = editor.selectedRanges.reverse()
for (let range of selectedRanges) {
// the text to be processed
let text = editor.getTextInRange(range)
// get the range of the start of the line with selection to the start of
// the selection and calculate the amount of characters for indentation
let indentRange = new Range(editor.getLineRangeForRange(range).start, range.start)
let indentText = editor.getTextInRange(indentRange)
let indentText = (() => {
let charCount = editor.getTextInRange(indentRange).length
return ' '.repeat(charCount)
})()
nova.commands.invoke('figlet', figConfig, text, figletText => {
// convert the FIGlet string to an array of strings to make it
@ -128,11 +135,8 @@ nova.commands.register('figletTextEditor', editor => {
// the line with the selection was indented
if (!indentRange.empty) {
figletTextArr = figletTextArr.map((line, index) => {
if (index === 0) {
return `${line}`
} else {
if (index === 0) { return `${line}` }
return `${indentText}${line}`
}
})
}