updated to v1.11
This commit is contained in:
@ -1,3 +1,9 @@
|
||||
## Version 1.11
|
||||
- added option to use inline or block comments
|
||||
|
||||
## Version 1.10.3
|
||||
- updated README.md banner image
|
||||
|
||||
## Version 1.10.2
|
||||
- fixed right border not vertically aligning when right padding was set to 0
|
||||
|
||||
|
@ -91,27 +91,27 @@ nova.commands.register('figletTextEditor', editor => {
|
||||
}
|
||||
|
||||
let commentsEnabled = nova.config.get('figlet_text.comment', 'boolean')
|
||||
let commentType = nova.config.get('figlet_text.commentType', 'string')
|
||||
let commentPadding = nova.config.get('figlet_text.commentPadding', 'number')
|
||||
let commentPaddingStr = nova.config.get('figlet_text.commentPaddingStr', 'string')
|
||||
const getCommentChars = () => {
|
||||
switch (editor.document.syntax) {
|
||||
case 'css':
|
||||
case 'scss':
|
||||
return {start: '/*', end: '*/'}
|
||||
return {block: {start: '/*', end: '*/'}, inline: {start: '/*', end: '*/'}}
|
||||
case 'html':
|
||||
return {start: '<!--', end: '-->'}
|
||||
return {block: {start: '<!--', end: '-->'}, inline: {start: '<!--', end: '-->'}}
|
||||
case 'javascript':
|
||||
case 'typescript':
|
||||
case 'php':
|
||||
return {start: '//', end: ''}
|
||||
return {block: {start: '/*', end: '*/'}, inline: {start: '//', end: ''}}
|
||||
default:
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
// subtract one; will Array.prototype.join('\n') before final editor output
|
||||
let prependNewLines = nova.config.get('figlet_text.prependNewLines', 'number') - 1
|
||||
let appendNewLines = nova.config.get('figlet_text.appendNewLines', 'number') - 1
|
||||
let prependNewLines = nova.config.get('figlet_text.prependNewLines', 'number')
|
||||
let appendNewLines = nova.config.get('figlet_text.appendNewLines', 'number')
|
||||
|
||||
let selectedRanges = editor.selectedRanges.reverse()
|
||||
|
||||
@ -233,6 +233,8 @@ nova.commands.register('figletTextEditor', editor => {
|
||||
// comment each line if the option is selected and a
|
||||
// comment structure is defined for the current syntax
|
||||
if (commentsEnabled && getCommentChars() !== null) {
|
||||
switch (commentType) {
|
||||
case 'inline':
|
||||
// find the longest line so we can add whitespace to shorter
|
||||
// lines so closing comments line up if the syntax uses them
|
||||
let longestLine = 0
|
||||
@ -246,13 +248,20 @@ nova.commands.register('figletTextEditor', editor => {
|
||||
|
||||
// return the commented line if not whitespace
|
||||
if (/^\s+$/.test(line)) return '\n'
|
||||
return `${getCommentChars().start}${commentPaddingStr.repeat(commentPadding)}${line}${' '.repeat(linePadding)}${commentPaddingStr.repeat(commentPadding)}${getCommentChars().end}`.trimEnd()
|
||||
return `${getCommentChars().inline.start}${commentPaddingStr.repeat(commentPadding)}${line}${' '.repeat(linePadding)}${commentPaddingStr.repeat(commentPadding)}${getCommentChars().inline.end}`.trimEnd()
|
||||
})
|
||||
break
|
||||
case 'block':
|
||||
figletTextArr.unshift(getCommentChars().block.start)
|
||||
figletTextArr.push(getCommentChars().block.end)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// prepend/append new lines
|
||||
if (prependNewLines > 0) figletTextArr = [`${'\n'.repeat(prependNewLines)}`].concat(figletTextArr)
|
||||
if (appendNewLines > 0) figletTextArr = figletTextArr.concat([`${'\n'.repeat(appendNewLines)}`])
|
||||
// subtract one; Array.prototype.join('\n') before editor output
|
||||
if (prependNewLines > 0) figletTextArr = [`${'\n'.repeat(prependNewLines - 1)}`].concat(figletTextArr)
|
||||
if (appendNewLines > 0) figletTextArr = figletTextArr.concat([`${'\n'.repeat(appendNewLines - 1)}`])
|
||||
|
||||
// indent subsequent lines after the first if
|
||||
// the line with the selection was indented
|
||||
|
@ -3,7 +3,7 @@
|
||||
"name": "FIGlet Text",
|
||||
"organization": "Dan Remollino",
|
||||
"description": "Convert selected text to FIGlet. Great for adding readable text to the Minimap, creating l33t text headers, and organizing files.",
|
||||
"version": "1.10.2",
|
||||
"version": "1.11",
|
||||
"categories": ["commands", "formatters"],
|
||||
|
||||
"entitlements": {
|
||||
@ -518,6 +518,14 @@
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"key": "figlet_text.commentType",
|
||||
"title": "Comment Type",
|
||||
"description": "Comment output line by line or as a single block.",
|
||||
"type": "enum",
|
||||
"values": [["inline", "Inline"], ["block", "Block"]],
|
||||
"default": "inline"
|
||||
},
|
||||
{
|
||||
"key": "figlet_text.commentPadding",
|
||||
"title": "Comment Padding",
|
||||
|
Reference in New Issue
Block a user