diff --git a/src/Apps/NetPad.Apps.App/App/src/core/@plugins/omnisharp/utils/text-change-util.ts b/src/Apps/NetPad.Apps.App/App/src/core/@plugins/omnisharp/utils/text-change-util.ts index 78cb55fb..d076771c 100644 --- a/src/Apps/NetPad.Apps.App/App/src/core/@plugins/omnisharp/utils/text-change-util.ts +++ b/src/Apps/NetPad.Apps.App/App/src/core/@plugins/omnisharp/utils/text-change-util.ts @@ -84,8 +84,10 @@ export class TextChangeUtil { } private static getNamespacesFromUsings(textChange: LinePositionSpanTextChange): string[] { - return textChange.newText?.split("\n") - .filter(l => !!l && l.trim()) + return textChange.newText + ?.split("\n") + .map(l => l?.trim()) // to remove empty parts + .filter(l => !!l) .map(l => Util.trimWord(l, "using ")) .map(l => Util.trimEnd(l, ";")) .map(l => l.trim()) diff --git a/src/Apps/NetPad.Apps.App/Startup.cs b/src/Apps/NetPad.Apps.App/Startup.cs index 61b6c449..c282ef55 100644 --- a/src/Apps/NetPad.Apps.App/Startup.cs +++ b/src/Apps/NetPad.Apps.App/Startup.cs @@ -78,7 +78,7 @@ public void ConfigureServices(IServiceCollection services) services.AddTransient(); services.AddTransient(); services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); // Scripts services.AddTransient(); diff --git a/src/Core/NetPad.Application/Sessions/Session.cs b/src/Core/NetPad.Application/Sessions/Session.cs index 6475ce2e..6ff5c181 100644 --- a/src/Core/NetPad.Application/Sessions/Session.cs +++ b/src/Core/NetPad.Application/Sessions/Session.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Logging; +using NetPad.Data; using NetPad.Events; using NetPad.Exceptions; using NetPad.Scripts; @@ -7,7 +8,10 @@ namespace NetPad.Sessions; public class Session : ISession { + private const string CurrentActiveSaveKey = "session.active"; + private readonly IScriptEnvironmentFactory _scriptEnvironmentFactory; + private readonly ITrivialDataStore _trivialDataStore; private readonly IEventBus _eventBus; private readonly ILogger _logger; private readonly List _environments; @@ -15,10 +19,12 @@ public class Session : ISession public Session( IScriptEnvironmentFactory scriptEnvironmentFactory, + ITrivialDataStore trivialDataStore, IEventBus eventBus, ILogger logger) { _scriptEnvironmentFactory = scriptEnvironmentFactory; + _trivialDataStore = trivialDataStore; _eventBus = eventBus; _logger = logger; _environments = new List(); @@ -53,17 +59,21 @@ public async Task OpenAsync(Script script, bool activate = true) public async Task OpenAsync(IEnumerable