git-sim icon indicating copy to clipboard operation
git-sim copied to clipboard

Issue with long file paths

Open eltoncezar opened this issue 2 years ago • 4 comments

I ran git-sim status on my repo, and this was the result:

image

eltoncezar avatar Jan 25 '23 22:01 eltoncezar

@eltoncezar LOL... I see how that can be a problem. Thinking about what the best way to address this... Obviously the file paths need to be truncated to a maximum length, and I think it makes sense to truncate them working backwards from the end of the filename/path. That way you will always at least see the filename itself, even if you are missing some of the beginning parts of the path which can usually be inferred.

Let me know if that makes sense - I will try and put in a fix for this later today.

initialcommit-io avatar Jan 25 '23 23:01 initialcommit-io

Yeah, it's a tricky problem to address. I think that there are 3 options:

  1. Truncate the beginning: .......filename That will address most of the scenarios, but can be problematic if you have files with the same name, but in different folders.

  2. Truncate the ending: filename...... That's dumb. Please don't do that.

  3. Truncate the middle: path.......filename That kinda solves the first option problem, but can be problematic if the path and the filename are too long, like my example.

I think that ideally, we should set a maximum length, try to keep the full filename and truncate the preceding folder structure. What you think about it?

eltoncezar avatar Jan 25 '23 23:01 eltoncezar

Thx for the suggestions. I think I will try out the option I suggested of setting the max length of the path and work backwards from the end of the string, that way we get as much as possible useful information for locating the file, and maximize the chance that unique parts of the path are shown.

The only scenario I think this doesn't handle is when the filename itself exceeds the max length. In that case it might be best to so something like: starting_chars_of_filename......ending_chars_of_filename

I'll let you know once I implement so that you can give it a try!

initialcommit-io avatar Jan 25 '23 23:01 initialcommit-io

I ended up doing it like this: first 5 chars + ... + last 15 chars.

This is deployed in git-sim version 0.1.5. Please upgrade using pip install git-sim --upgrade and let me know if any issues after you test.

initialcommit-io avatar Jan 26 '23 05:01 initialcommit-io

@eltoncezar Let me know when you get a chance to test this out, and if the fix works OK for you.

initialcommit-io avatar Jan 27 '23 17:01 initialcommit-io

@eltoncezar Closing since this should be fixed now. Feel free to reopen if any issues.

initialcommit-io avatar Jan 29 '23 17:01 initialcommit-io

Thanks for the quick fix! Now it looks like this: image

Much more manageable. But... I think it should use all the available space if possible. What do you think about it?

eltoncezar avatar Jan 30 '23 18:01 eltoncezar