I suppose it's really a refactoring browser issue, rather that Dolphin
though....
Say you have creating/editing a method and end up with red underlining
and the status bar showing "missing )". My immediate reaction is to
do refactor/accept, so that the bracket mismatch becomes more obvious.
A simplified example, for the purposes of this post, might be
aa
(self
aa;
aa.) self aa
During the editing the period has been, incorrectly, moved inside the
bracket. A refactor/accept then gives you
aa
self
aa;
aa
The removed, possibly edited, code at the end of the method has just
gone; it's not in the change log and Ctrl-Z won't bring it back.
A few possible solutions come to mind; perhaps I shall investigate...
- Reformat/accept is disabled on methods with errors (not warnings)
- Reformat/accept is disabled if one of the hidden error messages is
"nonsense at end of method"
- Copy text to the clipboard (or change log) before refactoring
methods with errors
Glad to have got that off my chest. Now back to waiting for the wind
(rather blowy here at the minute) to blow a tree over onto my car....
Ian
--
The From address is valid
For the record, I went with that one ...
MethodWorkspace>>queryCommand:
remove the statement that provides a common check for #accept and
#reformatAccept. Replace it with
#accept == selector
ifTrue:
[aCommandQuery isEnabled: self canSaveMethod.
^true].
#reformatAccept == selector
ifTrue:
[aCommandQuery
isEnabled:
self canSaveMethod &
(compilationErrors allSatisfy: [:each | each severityClass ~~ Error]).
^true].
Seems to work as advertised ...
I encourage you to go for less infantilization & totalitarianism and
more error recovery & empowerment. Smalltalk is Freedom & Light after
all, not Bondage & Discipline.
Simultaneously, I strongly DIScourage you from messing with the
clipboard. EVER. The user OWNS that so you MAY NOT interfere.
So the change log is one possibility. Another is to preserve the last
few edit buffers and make them available from the Edit menubar,
possibly under >>Past Buffers or just >>Buffers. Presumably they would
insert the buffer at the cursor position.
Some umm, interesting, imagery there :-)
I'm quite happy now with the way I "fixed" it, by disabling the menu
option. I wish I'd looked into it earlier.
My normal method of accepting source is right-click then
reformat/accept. I do it automatically, without really thinking, and I
suppose that was the underlying problem.
The only thing I lose by disabling the menu option, if the method
contains errors, is the possibility of losing source. I can still
reformat the code, to make spotting mismatching braces easier for
example, but only by using an option that makes any deleted source
recoverable (via Ctrl-Z).
Why not work with this for a bit and then, if you're happy with the
outcome, I'll incorporate the fix in the base.
Best regards
Andy Bower