Hi Eran,
Recently i used File Replace Candidates Option in Find in Files Dialog. After replacing a word in many Files, CL Triggers the FIle change detection/reload Window even though i used CL built in Features to replcae words globally. Is this intentional
Regards
Gururaja
BUG: Find Replace Candidates usage trigger file change detec
-
- CodeLite Expert
- Posts: 113
- Joined: Fri Jul 11, 2008 9:12 am
- Contact:
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: BUG: Find Replace Candidates usage trigger file change detec
Since the replacement was done on the disk and not via the editor - codelite detected that the file which is opened is not synchronized with the one on the disk, this is why you get this message.
This behavior is not going to be modified (performing the replace directly on the disk instead of the editing the open editors) the only thing that might be modified, is maybe prompting once instead of many time
Eran
This behavior is not going to be modified (performing the replace directly on the disk instead of the editing the open editors) the only thing that might be modified, is maybe prompting once instead of many time
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Veteran
- Posts: 69
- Joined: Fri Oct 24, 2008 10:29 pm
- Contact:
Re: BUG: Find Replace Candidates usage trigger file change detec
Eran,
What do you think of this: Add a "needs to be reloaded" flag to LEditor. It gets set in each editor whenever the user does an action that affects the editor's file, but where you are going to modify the file on disk directly. If the editor is dirty, it should get saved at that time, by the same LEditor method that sets this flag. Then, in the LEditor::SetActive() function, you check the flag and if it's set, Reload() the file. Thus there won't be a sequence of "File changed, would you like to reload" question boxes. And no big delay reloading all modified files at once since reloading each editor is deferred till the user activates it.
Scott
What do you think of this: Add a "needs to be reloaded" flag to LEditor. It gets set in each editor whenever the user does an action that affects the editor's file, but where you are going to modify the file on disk directly. If the editor is dirty, it should get saved at that time, by the same LEditor method that sets this flag. Then, in the LEditor::SetActive() function, you check the flag and if it's set, Reload() the file. Thus there won't be a sequence of "File changed, would you like to reload" question boxes. And no big delay reloading all modified files at once since reloading each editor is deferred till the user activates it.
Scott
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: BUG: Find Replace Candidates usage trigger file change detec
So we should identify all parts of code that modifies the file directly and not via the editor?sdolim wrote:t gets set in each editor whenever the user does an action that affects the editor's file
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Veteran
- Posts: 69
- Joined: Fri Oct 24, 2008 10:29 pm
- Contact:
Re: BUG: Find Replace Candidates usage trigger file change detec
In each routine where you modify one or more disk files directly, you would add code to loop over the open editors first. If an editor's filename is in the list of files you plan to modify, call this new method "LEditor::SetNeedsReload()" on that editor. The method will save the editor (if it's modified), and set the new flag "m_needsReload" in the editor object.eranif wrote: So we should identify all parts of code that modifies the file directly and not via the editor?
Eran
After that loop is done, the routine can rewrite files on disk without worry.
Afterwards, each editor whose file got modified will automatically reload only when the user selects the editor, because LEditor::SetActive() will check m_needsReload and call the reload method if it is set. It won't have to ask the user because it was already saved.
The result is that we don't bother the user with a lot of "File modified outside editor, do you want to reload?" dialogs. Also there won't be a long delay from reloading a bunch of editors at one time.
Scott
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: BUG: Find Replace Candidates usage trigger file change detec
I dont think it is a good idea to save files without asking the user permission. I mean, I think that the problem is with files which are un-modified (which is usually the majority), but CodeLIte keep asking you for each and everyone. The solution should be a lot simpler:sdolim wrote:The method will save the editor (if it's modified)
- If CodeLite modified a file which is open in an editor and that file is un-modified -> reload it without asking the user since no harm is done (however, breakpoints, bookmarks and line / position should be kept using LEditor::G/SetEditorState() )
- If the file is modified in the editor, ask the user to save the file *before* the change is taking place, something like "CodeLite is about to modify some files on the disk, would you like to save the file before proceeding?" [Yes/No]
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Veteran
- Posts: 69
- Joined: Fri Oct 24, 2008 10:29 pm
- Contact:
Re: BUG: Find Replace Candidates usage trigger file change detec
That sounds good. I would put all that logic (ask user to save if modified, save file if user answers yes, set m_needsReload) into one method of LEditor. It could return false if the user doesn't want to save the modified file -- in that case the file should be dropped from the list of files to be modified. So the name "LEditor::SetNeedsReload" is no longer a good name. Instead it should be something like "LEditor::IsOKToModify".
To be clear: this is the logic for one editor. There still needs to be a loop over the editors, which calls this method if the editor's filename is in the list.
To be clear: this is the logic for one editor. There still needs to be a loop over the editors, which calls this method if the editor's filename is in the list.
- eranif
- CodeLite Plugin
- Posts: 6375
- Joined: Wed Feb 06, 2008 9:29 pm
- Genuine User: Yes
- IDE Question: C++
- Contact:
Re: BUG: Find Replace Candidates usage trigger file change detec
Great, so from reading this, I guess that you will be the one implementing this?sdolim wrote:That sounds good. I would put all that logic (ask user to save if modified, save file if user answers yes, set m_needsReload) into one method of LEditor.
Eran
Make sure you have read the HOW TO POST thread
-
- CodeLite Veteran
- Posts: 69
- Joined: Fri Oct 24, 2008 10:29 pm
- Contact: