Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #28 #29

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
741 changes: 535 additions & 206 deletions BumbleBee.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions BumbleBee.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -9,14 +9,14 @@
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5C3BE82719EEF85700FEDF2B"
BuildableName = "BumbleBee.temp_caseinsensitive_renameTests.xctest"
BlueprintName = "BumblebeeTests"
BlueprintIdentifier = "NT_919963003752"
BuildableName = "Bumblebee.framework"
BlueprintName = "Bumblebee_iOS"
ReferencedContainer = "container:BumbleBee.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -26,25 +26,27 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5C3BE82719EEF85700FEDF2B"
BuildableName = "BumbleBee.temp_caseinsensitive_renameTests.xctest"
BlueprintName = "BumblebeeTests"
BlueprintIdentifier = "NT_533142740653"
BuildableName = "BumblebeeTests.xctest"
BlueprintName = "BumblebeeTests_iOS"
ReferencedContainer = "container:BumbleBee.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5C3BE82719EEF85700FEDF2B"
BuildableName = "BumbleBee.temp_caseinsensitive_renameTests.xctest"
BlueprintName = "BumblebeeTests"
BlueprintIdentifier = "NT_919963003752"
BuildableName = "Bumblebee.framework"
BlueprintName = "Bumblebee_iOS"
ReferencedContainer = "container:BumbleBee.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand All @@ -55,21 +57,23 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5C3BE82719EEF85700FEDF2B"
BuildableName = "BumbleBee.temp_caseinsensitive_renameTests.xctest"
BlueprintName = "BumblebeeTests"
BlueprintIdentifier = "NT_919963003752"
BuildableName = "Bumblebee.framework"
BlueprintName = "Bumblebee_iOS"
ReferencedContainer = "container:BumbleBee.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
Expand All @@ -79,15 +83,16 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5C3BE82719EEF85700FEDF2B"
BuildableName = "BumbleBee.temp_caseinsensitive_renameTests.xctest"
BlueprintName = "BumblebeeTests"
BlueprintIdentifier = "NT_919963003752"
BuildableName = "Bumblebee.framework"
BlueprintName = "Bumblebee_iOS"
ReferencedContainer = "container:BumbleBee.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -14,23 +14,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5CDE6C1519F19E4D00509EE9"
BlueprintIdentifier = "NT_526567392730"
BuildableName = "Bumblebee.framework"
BlueprintName = "BumblebeeOSX"
ReferencedContainer = "container:BumbleBee.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5CDE6C1F19F19E4D00509EE9"
BuildableName = "BumblebeeOSXTests.xctest"
BlueprintName = "BumblebeeOSXTests"
BlueprintName = "Bumblebee_macOS"
ReferencedContainer = "container:BumbleBee.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -40,25 +26,27 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5CDE6C1F19F19E4D00509EE9"
BuildableName = "BumblebeeOSXTests.xctest"
BlueprintName = "BumblebeeOSXTests"
BlueprintIdentifier = "NT_537431329142"
BuildableName = "BumblebeeTests.xctest"
BlueprintName = "BumblebeeTests_macOS"
ReferencedContainer = "container:BumbleBee.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5CDE6C1519F19E4D00509EE9"
BlueprintIdentifier = "NT_526567392730"
BuildableName = "Bumblebee.framework"
BlueprintName = "BumblebeeOSX"
BlueprintName = "Bumblebee_macOS"
ReferencedContainer = "container:BumbleBee.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand All @@ -69,21 +57,23 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5CDE6C1519F19E4D00509EE9"
BlueprintIdentifier = "NT_526567392730"
BuildableName = "Bumblebee.framework"
BlueprintName = "BumblebeeOSX"
BlueprintName = "Bumblebee_macOS"
ReferencedContainer = "container:BumbleBee.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
Expand All @@ -93,15 +83,16 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5CDE6C1519F19E4D00509EE9"
BlueprintIdentifier = "NT_526567392730"
BuildableName = "Bumblebee.framework"
BlueprintName = "BumblebeeOSX"
BlueprintName = "Bumblebee_macOS"
ReferencedContainer = "container:BumbleBee.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -14,9 +14,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5C3BE81C19EEF85700FEDF2B"
BlueprintIdentifier = "NT_458247305677"
BuildableName = "Bumblebee.framework"
BlueprintName = "Bumblebee"
BlueprintName = "Bumblebee_watchOS"
ReferencedContainer = "container:BumbleBee.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand All @@ -26,31 +26,54 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "NT_661919236675"
BuildableName = "BumblebeeTests.xctest"
BlueprintName = "BumblebeeTests_watchOS"
ReferencedContainer = "container:BumbleBee.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "NT_458247305677"
BuildableName = "Bumblebee.framework"
BlueprintName = "Bumblebee_watchOS"
ReferencedContainer = "container:BumbleBee.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5C3BE81C19EEF85700FEDF2B"
BlueprintIdentifier = "NT_458247305677"
BuildableName = "Bumblebee.framework"
BlueprintName = "Bumblebee"
BlueprintName = "Bumblebee_watchOS"
ReferencedContainer = "container:BumbleBee.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
Expand All @@ -60,15 +83,16 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "5C3BE81C19EEF85700FEDF2B"
BlueprintIdentifier = "NT_458247305677"
BuildableName = "Bumblebee.framework"
BlueprintName = "Bumblebee"
BlueprintName = "Bumblebee_watchOS"
ReferencedContainer = "container:BumbleBee.xcodeproj">
</BuildableReference>
</MacroExpansion>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
File renamed without changes.
39 changes: 19 additions & 20 deletions Sources/bumblebee.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ open class Parser {
let regex = try opt.pattern.regex()
var diff = 0
let mutText = mutStr.string
let matches = regex.matches(in: mutText, range: NSMakeRange(0, mutStr.string.utf16.count))
let matches = regex.matches(in: mutText, range: NSMakeRange(0, mutStr.string.count))
for result in matches {
if result.numberOfRanges > 0 {
let range = result.range(at: 0)
Expand All @@ -88,25 +88,24 @@ open class Parser {
}
let start = mutText.index(mutText.startIndex, offsetBy: range.location)
let end = mutText.index(mutText.startIndex, offsetBy: range.location + range.length)

if let str = String(mutText.utf16[start..<end]) {
let transform = opt.pattern.transform(text: str)
let response = opt.matched(transform.text, transform.attributes)

//diff range accounts for any char changes (string is now a different length)
let diffRange = NSMakeRange(location + diff, range.length)
//merge and apply attributes
var attrs = mutStr.attributes(at: diffRange.location, longestEffectiveRange: nil, in: diffRange)
if let newAttrs = response.attributes {
for (key, value) in newAttrs {
attrs[key] = value
}
}
//create an attributed string with the attributes of the orignial string with any new additions for the matched response
let replaceStr = NSAttributedString(string: response.string, attributes: attrs)
diff += response.string.utf16.count - str.utf16.count
mutStr.replaceCharacters(in: diffRange, with: replaceStr)
}

let str = String(mutText[start..<end])
let transform = opt.pattern.transform(text: str)
let response = opt.matched(transform.text, transform.attributes)

//diff range accounts for any char changes (string is now a different length)
let diffRange = NSMakeRange(location + diff, range.length)
//merge and apply attributes
var attrs = mutStr.attributes(at: diffRange.location, longestEffectiveRange: nil, in: diffRange)
if let newAttrs = response.attributes {
for (key, value) in newAttrs {
attrs[key] = value
}
}
//create an attributed string with the attributes of the orignial string with any new additions for the matched response
let replaceStr = NSAttributedString(string: response.string, attributes: attrs)
diff += response.string.count - str.count
mutStr.replaceCharacters(in: diffRange, with: replaceStr)
}
}
} catch {
Expand Down
Loading