Skip to content

Commit

Permalink
Allow openScriptsExternally option to be changed during sync
Browse files Browse the repository at this point in the history
  • Loading branch information
nezuo committed May 8, 2024
1 parent 41443d3 commit 4f1ea91
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
1 change: 0 additions & 1 deletion plugin/src/App/StatusPages/Settings/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ function SettingsPage:render()
id = "openScriptsExternally",
name = "Open Scripts Externally",
description = "Attempt to open scripts in an external editor",
locked = self.props.syncActive,
experimental = true,
transparency = self.props.transparency,
layoutOrder = layoutIncrement(),
Expand Down
8 changes: 1 addition & 7 deletions plugin/src/App/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -425,20 +425,14 @@ function App:startSession()

local host, port = self:getHostAndPort()

local sessionOptions = {
openScriptsExternally = Settings:get("openScriptsExternally"),
twoWaySync = Settings:get("twoWaySync"),
}

local baseUrl = if string.find(host, "^https?://")
then string.format("%s:%s", host, port)
else string.format("http://%s:%s", host, port)
local apiContext = ApiContext.new(baseUrl)

local serveSession = ServeSession.new({
apiContext = apiContext,
openScriptsExternally = sessionOptions.openScriptsExternally,
twoWaySync = sessionOptions.twoWaySync,
twoWaySync = Settings:get("twoWaySync"),
})

self.cleanupPrecommit = serveSession.__reconciler:hookPrecommit(function(patch, instanceMap)
Expand Down
5 changes: 2 additions & 3 deletions plugin/src/ServeSession.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local InstanceMap = require(script.Parent.InstanceMap)
local PatchSet = require(script.Parent.PatchSet)
local Reconciler = require(script.Parent.Reconciler)
local strict = require(script.Parent.strict)
local Settings = require(script.Parent.Settings)

local Status = strict("Session.Status", {
NotStarted = "NotStarted",
Expand Down Expand Up @@ -50,7 +51,6 @@ ServeSession.Status = Status

local validateServeOptions = t.strictInterface({
apiContext = t.table,
openScriptsExternally = t.boolean,
twoWaySync = t.boolean,
})

Expand Down Expand Up @@ -89,7 +89,6 @@ function ServeSession.new(options)
self = {
__status = Status.NotStarted,
__apiContext = options.apiContext,
__openScriptsExternally = options.openScriptsExternally,
__twoWaySync = options.twoWaySync,
__reconciler = reconciler,
__instanceMap = instanceMap,
Expand Down Expand Up @@ -170,7 +169,7 @@ function ServeSession:__applyGameAndPlaceId(serverInfo)
end

function ServeSession:__onActiveScriptChanged(activeScript)
if not self.__openScriptsExternally then
if not Settings:get("openScriptsExternally") then
Log.trace("Not opening script {} because feature not enabled.", activeScript)

return
Expand Down

0 comments on commit 4f1ea91

Please sign in to comment.