Closed Bug 463003 Opened 14 years ago Closed 14 years ago

Context menu for selected text in content shows all items


(Thunderbird :: Mail Window Front End, defect, P1)



(Not tracked)

Thunderbird 3.0b1


(Reporter: philor, Assigned: philor)



(Keywords: dev-doc-complete, regression)


(1 file, 1 obsolete file)

Attached patch Fix v.1 (obsolete) — Splinter Review
More fallout from my worst-ever job of reviewing, in bug 461112. We have an unimplemented, never shown or used backend for a context menuitem to search for selected text (copied from Fx's copying from SM), that I couldn't quite bear to tear out when I rewrote nsContextMenu.js. Even though I saw that the patch in 461112 was removing the searchText string and switching to loading instead of, I failed to notice that the patch wasn't actually adding searchText there.

But, in keeping with my claim that you shouldn't ever use strings which have been translated unused and unseen for years, the right thing to do is not to just add it back, and make localizers retranslate it while still not being able to see the result. Much as I hate to see it go, the right thing is to rip out the unused code until we actually use it.
Attachment #346224 - Flags: review?(bugzilla)
Priority: -- → P1
Thanks for patching my incomplete patch. 
And thanks for giving me the ability to show that we have lots of unused areas of code, by delivering an incomplete patch :)
Comment on attachment 346224 [details] [diff] [review]
Fix v.1

So the patch reduces to:

>   isTextSelection : function CM_isTextSelection() {
>     var selection = this.searchSelected();
>+    if (selection != "")
>+      return true;
>+    return false;

how about:

return this.searchSelected();

much simpler.
Comment on attachment 346224 [details] [diff] [review]
Fix v.1

Then I'll be forced to accept that there's no point in having a separate function, and no point in normalizing the whitespace, and before you know it I'll find myself fixing our share of bug 272041, too.
Attachment #346224 - Attachment is obsolete: true
Attachment #346224 - Flags: review?(bugzilla)
Attached patch Fix v.2Splinter Review
I guess actually fixing something is better than just preserving my favorite unused code.
Attachment #346412 - Flags: review?(bugzilla)
Attachment #346412 - Flags: review?(bugzilla) → review+
Closed: 14 years ago
Resolution: --- → FIXED
For those who need the removed gContextMenu.isTextSelected (extensions ported from Firefox) here's the replacement:

var isTextSelected = false;
if (gContextMenu.isContentSelected) {
  var selection = document.commandDispatcher.focusedWindow.
      getSelection().toString().replace(/(\n|\r|\t)+/g, " ").trim();
  isTextSelected = (selection != "");

I'm linking this from and
You need to log in before you can comment on or make changes to this bug.