Commits

Lynn Rees committed ba98131

- "wikdNode" delete* handles "Cancel" properly

Comments (0)

Files changed (3)

scripts/deleteFirstChars.groovy

 import org.apache.commons.lang.StringUtils as SU
 
 def trimPrompt(String pattern, Boolean start, String msg) {
-	def mark = Pattern.quote(ui.showInputDialog(node.delegate, msg, ''))
-	mark = mark ? mark : ''
-	mark = start ? pattern + mark : mark + pattern
+	def mark = ui.showInputDialog(node.delegate, msg, '')
+	if (mark != null) {
+	   mark = Pattern.quote(start ? pattern + mark : mark + pattern)
+	}
 	c.selecteds.every { it.text = SU.trim( it.plainText.replaceFirst(mark, '')) }
 }
 trimPrompt('^{1}', true, 'Enter characters to delete from text start...')

scripts/deleteLastChars.groovy

 import org.apache.commons.lang.StringUtils as SU
 
 def trimPrompt(String pattern, Boolean start, String msg) {
-	def mark = Pattern.quote(ui.showInputDialog(node.delegate, msg, ''))
-	mark = mark ? mark : ''
-	mark = start ? pattern + mark : mark + pattern
+	def mark = ui.showInputDialog(node.delegate, msg, '')
+	if (mark != null) {
+	   mark = Pattern.quote(start ? pattern + mark : mark + pattern)
+	}
 	c.selecteds.every { it.text = SU.trim( it.plainText.replaceFirst(mark, '')) }
 }
 trimPrompt('{1}$', false, 'Enter characters to delete from text end:')

shared/delete.groovy

 import org.apache.commons.lang.StringUtils as SU
 
 def trimPrompt(String pattern, Boolean start, String msg) {
-	def mark = Pattern.quote(ui.showInputDialog(node.delegate, msg, ''))
-	mark = mark ? mark : ''
-	mark = start ? pattern + mark : mark + pattern
+	def mark = ui.showInputDialog(node.delegate, msg, '')
+	if (mark != null) {
+	   mark = Pattern.quote(start ? pattern + mark : mark + pattern)
+	}
 	c.selecteds.every { it.text = SU.trim( it.plainText.replaceFirst(mark, '')) }
 }