jonhoo/inferno

Cut off left part of text, rather than right part of text when SVG is too small

itamarst opened this issue · 3 comments

Let's say your function is too wide to fit on the screen. Right now, the right side will be truncated:

for (var x = txt.length - 2; x > 0; x--) {
        if (t.getSubStringLength(0, x + 2) <= w) {
            t.textContent = txt.substring(0, x) + "..";
            return;
        }
    }
    t.textContent = "";

So e.g. in my case I have /home/itamarst/Devel/memory-profiler/venv/lib64/python3.8/site-packages/numpy/core/numeric.py:ones truncated to /home/itamarst/Devel/memory-profiler/venv/lib64/...

But, you'll notice the most significant information is on the right side of that string: the function name, the main file, etc. It would be better to truncate it in the opposite direction: ../python3.8/site-packages/numpy/core/numeric.py:ones, or at least have that as a rendering option.

Oh, and of course, thank you for writing this library! It's really great.

Hmm, that's interesting. I'm honestly not sure what the right thing to do here is. I suspect you're right that the right-hand side is "better" than the left-hand side, but only up to a point. If you get, for example, mod.rs as the cropped text, it's pretty much useless. But then again, so would /home/ be in that case. If you submit a PR for this I think I'd be inclined to merge it :)

cc @jasonrhansen

I'll see if I can make it an option, rather than just changing it.