SciTE will display the spurious error 'The file '<path to working directory>' has been deleted' in a message box after running a custom Lua function from the Tool menu if:
load.on.activate is set to 1.Example Lua function:
function sort_text()
local sel = editor:GetSelText()
if #sel == 0 then return end
local eol = string.match(sel, "\n$")
local buf = lines(sel)
--table.foreach(buf, print) --used for debugging
table.sort(buf)
local out = table.concat(buf, "\n")
if eol then out = out.."\n" end
editor:ReplaceSel(out)
end
Tool menu entry:
command.name.1.*=Sort Lines
command.subsystem.1.*=3
command.1.*=sort_text
command.save.before.1.*=2
Patch is attached that modifies CheckReload() to do nothing if the current filePath is an Untitled file.
This does not occur for me and the path through the code should not be possible.
newModTimewill be 0 because there is a check for untitled inFilePath::ModifiedTimethat returns 0. Then there must be a non-0 value inCurrentBuffer()->fileModTimewhich shouldn't be possible since it is for an untitled buffer. Possibly something more complex is occurring.The above example is missing a
linesfunction.Here's the
lines()function:I tested with and without my change, and it definitely made the error dialog go away. I've attached an example of the error dialog for reference.
I added some logs, and what's happening is
command.is.filteris being read as set byJobMode::JobMode(), soisFilteris set. Is that the default? I did not set it in my tool.That causes
SciTEBase::ToolsMenu()to setCurrentBuffer()->fileModTimeto-1, which meets all the criteria for the conditional to hit for the error message on an Untitled buffer.Check for overlapping command patterns. If there are two patterns like
*.javaand*.cppspecifying properties, the priority is not obvious. The standard properties only specify a few filter properties for*.solandcommand.is.filter.0.$(file.patterns.cpp)which is for command 0 so shouldn't interfere with your command 1. As well ascommand.is.filter,command.modemay set the filter state.The filter code could be improved as the time hack to force reload isn't great.
Sure, but that still means that a command that is set as a filter (not that I know what that means) will produce this spurious error message?
Also perhaps the code that job mode is calling is assuming that all files have extensions, which could be what is causing some of the unpredictable behavior? I'd have to dig into that more though, ideally with a debugger.
(never mind about the -1 mod time comment, I think I misunderstood.)
I will look at my properties later, I don't have them on hand right at the moment. Thank you for your time thus far!
Last edit: Mark W. Gabby-Li 6 days ago
Digging into my properties, I don't see any filter settings at all for any commands, nor any use of
command.mode. I've attached all the options files and my Lua startup script to this comment. Note that I'm on Windows and I've seen this behavior on the latest in hg as of my report.When the call is made to get the filter status of the command in the
JobModeconstructor,propNameiscommand.is.filter.1., andfileNameExtis empty.Wasn't able to reproduce with those files.
It's better to find the base cause of this bug instead of recovering in
CheckReloadas the bug may cause other problems.The main things I'm imaging could be wrong are unexpected command properties or incorrect wildcard matching. There are other settings that include "filter" so a spurious match may be possible.
Is it producing a non-empty
modeValinJobMode::JobModeand what is its value if it is non-empty?In the
props.GetWildfor "command.is.filter.", which return statement is hit and how many times did the mainwhile (psf) {loop iterate? That will show which property set was responsible. If its theMatchWildSetthat succeeds, what is theit->firstandkeyFile.The user properties includes
properties.directory.enable=1so check what is in the directory options file and also local options.Found it!
html.propertiesinC:\ProgramData\SciTE\. The broken property is in a Windows platform block! This is why it was happening for me but not you, you must be on a different platform (I was also not able to replicate it on Linux, so I just booted into Windows and found the error):Last edit: Mark W. Gabby-Li 5 days ago
That line isn't in the distributed html.properties (sourceforge.net). I have some recollection of setting up HTML Tidy to reformat HTML files so it may be in some other version of html.properties.
With that cleared up, it should be OK to stop the problem for untitled files by avoiding the decrement for invalid modification times. While there may be some benefit to running a filter like HTML Tidy on an untitled buffer, there would be the hassle of creating a temporary file and making sure to remove it later. The user can save the buffer into a real file if they want to do something with it.
Thanks. For full clarity, I believe my Windows installs came from the old "SciTE for Windows" installers, which may have had different versions of the property files?
I see the Windows installers are no longer available. I seem to remember they were provided by a third party rather than the project itself? Perhaps there was some mistake when packaging them and they included user-customized property file by accident, or perhaps they had intentional customizations.
Committed the above code with [1c0de1].
The installer appears to have been discontinued by its author. The customizations were part of the purpose of that project.
Related
Commit: [1c0de1]