Skip to content

Commit 79561bc

Browse files
authored
Check if path is empty so buffer is treated as file
1 parent c0bbb91 commit 79561bc

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

lua/salesforce/execute_anon.lua

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,24 @@ M.execute_anon = function()
2121
local file_type = vim.bo.filetype
2222
local default_username = OrgManager:get_default_username()
2323

24-
if file_type ~= "apex" then
24+
if file_type == "apex" then
25+
if path == "" then
26+
Debug:log("execute_anon.lua", "Executing anonymous Apex script for current buffer...")
27+
path = vim.fn.expand("%")
28+
if not default_username then
29+
Util.notify_default_org_not_set()
30+
return
31+
end
32+
else
33+
Debug:log("execute_anon.lua", "Executing anonymous Apex script for file...")
34+
end
35+
else
2536
local message = "Not an Apex script file"
2637
Debug:log("execute_anon.lua", message)
2738
vim.notify(message, vim.log.levels.ERROR)
2839
return
2940
end
3041

31-
if not default_username then
32-
Util.notify_default_org_not_set()
33-
return
34-
end
35-
3642
Popup:create_popup({})
3743
Popup:write_to_popup("Executing anonymous Apex script...")
3844
local executable = Config:get_options().sf_executable
@@ -73,4 +79,4 @@ M.execute_anon = function()
7379
end
7480
end
7581

76-
return M
82+
return M

0 commit comments

Comments
 (0)