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