A lot of modern bucket tools have tolerance settings that will allow it to fill colors beyond the one it's currently filling, so increasing the tolerance for the tool will fill right up to the edge of your lines a lot of the time. However, many artists, including myself, like to use textured lines, which complicates things a bit. The fill tool also chokes on dense hatching, so for my stuff the fill tool is basically worthless.