From 6bc9c7629aef36efef789870f89c6d7325035d0d Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Mon, 10 Jan 2022 10:28:20 +0800 Subject: [PATCH] feat: context's source ignore what behinds semicolon --- .../src/main/java/pub/doric/devkit/DoricDev.java | 7 ++++++- doric-iOS/Devkit/Classes/DoricDev.m | 11 ++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java index 1fda53a8..08bde479 100644 --- a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java @@ -240,7 +240,12 @@ public class DoricDev { List list = new ArrayList<>(); source = source.replace(".js", "").replace(".ts", ""); for (DoricContext context : DoricContextManager.aliveContexts()) { - String doricSource = context.getSource().replace(".js", "").replace(".ts", ""); + String doricSource = context.getSource(); + String[] split = doricSource.split(";"); + if (split.length > 1) { + doricSource = split[0]; + } + doricSource = doricSource.replace(".js", "").replace(".ts", ""); if (source.equals(doricSource) || doricSource.equals("__dev__")) { list.add(context); } diff --git a/doric-iOS/Devkit/Classes/DoricDev.m b/doric-iOS/Devkit/Classes/DoricDev.m index 99bb7f0e..017ce987 100644 --- a/doric-iOS/Devkit/Classes/DoricDev.m +++ b/doric-iOS/Devkit/Classes/DoricDev.m @@ -187,8 +187,13 @@ - (BOOL)isReloadingContext:(DoricContext *)context { withString:@"" ]; for (DoricContext *context in [DoricContextManager.instance aliveContexts]) { - NSString *contextSource = [[context.source stringByReplacingOccurrencesOfString:@".js" - withString:@""] + NSString *contextSource = context.source; + NSArray *split = [contextSource componentsSeparatedByString:@";"]; + if (split.count > 1) { + contextSource = split[0]; + } + contextSource = [[contextSource stringByReplacingOccurrencesOfString:@".js" + withString:@""] stringByReplacingOccurrencesOfString:@".ts" withString:@"" ]; @@ -288,7 +293,7 @@ - (NSString *)ip { // Return presented view controller return findBestViewController(vc.presentedViewController); } else if ([vc isKindOfClass:[UISplitViewController class]]) { - // Return right hand side + // Return right-hand side UISplitViewController *svc = (UISplitViewController *) vc; if (svc.viewControllers.count > 0) return findBestViewController(svc.viewControllers.lastObject);