From: will <phil....@gmail.com>
Date: Wed, 28 Sep 2011 17:52:35 -0700
Subject: Check for an empty string in get_selection()

The problem is that the get_selection method doesn't account for when
the "html text offset" command returns the empty string (it does, and
the C source says it can).

Origin: http://groups.google.com/group/tkhtml3/browse_thread/thread/9a624679a76e73cf
---
 hv/hv3.tcl | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hv/hv3.tcl b/hv/hv3.tcl
index 16b7c8c..e68896f 100644
--- a/hv/hv3.tcl
+++ b/hv/hv3.tcl
@@ -788,7 +788,7 @@ namespace eval ::hv3::hv3::selectionmanager {
 
   # get_selection OFFSET MAXCHARS
   #
-  #     This command is invoked whenever the current selection is selected
+  #     This command is invoked whenever the current selection is requested
   #     while it is owned by the html widget. The text of the selected
   #     region is returned.
   #
@@ -803,6 +803,9 @@ namespace eval ::hv3::hv3::selectionmanager {
 
     set stridx_a [$O(myHv3) html text offset $O(myFromNode) $O(myFromIdx)]
     set stridx_b [$O(myHv3) html text offset $O(myToNode) $O(myToIdx)]
+    if {$stridx_a eq "" || $stridx_b eq ""} {
+      return ""
+    }
     if {$stridx_a > $stridx_b} {
       foreach {stridx_a stridx_b} [list $stridx_b $stridx_a] {}
     }
