Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
itamarst opened this issue Jan 20, 2020 · 3 comments · Fixed by #157
Closed

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

itamarst opened this issue Jan 20, 2020 · 3 comments · Fixed by #157

Comments

@itamarst
Copy link
Contributor

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.

@itamarst
Copy link
Contributor Author

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

@jonhoo
Copy link
Owner

jonhoo commented Jan 20, 2020

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

@itamarst
Copy link
Contributor Author

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

jonhoo added a commit that referenced this issue Feb 2, 2020
#156: truncate text on the left by default, but make it configurable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants