FileConversionProject.findText
This commit is contained in:
@@ -9,6 +9,7 @@ import uuid.Uuid;
|
||||
import sys.io.File;
|
||||
import sys.FileSystem;
|
||||
using haxe.io.Path;
|
||||
using StringTools;
|
||||
|
||||
typedef Block = {
|
||||
id:String,
|
||||
|
@@ -228,4 +228,15 @@
|
||||
(let [vc (validConversions idx reportError)]
|
||||
(when (= 1 (count vc))
|
||||
(doFor =>conversionName text vc
|
||||
(editBlock idx null text null))))))
|
||||
(editBlock idx null text null))))))
|
||||
|
||||
(method :Null<Int> findText [:String text &opt :Int startingIdx :Bool caseSensitive]
|
||||
(let [blocksToCheck (enumerate blocks)
|
||||
blocksToCheck (if startingIdx (blocksToCheck.slice startingIdx) blocksToCheck)
|
||||
text (if caseSensitive text (text.toLowerCase))]
|
||||
(doFor [idx block] blocksToCheck
|
||||
(let [:String inText (if caseSensitive block.inText (block.inText.toLowerCase))
|
||||
:String outText (if caseSensitive block.outText (block.outText.toLowerCase))]
|
||||
(when (or (inText.contains text) (outText.contains text))
|
||||
(return idx))))
|
||||
null))
|
@@ -27,6 +27,9 @@
|
||||
(assertEquals "here\n\n" .inText (first project.blocks))
|
||||
(assertEquals "there" .inText (second project.blocks))
|
||||
|
||||
(assertEquals 0 (project.findText "here"))
|
||||
(assertEquals 1 (project.findText "here" 1))
|
||||
|
||||
// Test block joining
|
||||
(assert !(project.joinBlockDown 1))
|
||||
|
||||
|
Reference in New Issue
Block a user