Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Fix copy/pasting files under certain scenarios - #649

Merged
as-cii merged 22 commits into
masterfrom
wl-paste-fixes
May 17, 2016
Merged

as-cii merged 22 commits into
masterfrom
wl-paste-fixes

Conversation

@winstliu

Copy link
Copy Markdown
Contributor

This probably should have 2 separate commits, but oh well.

The two issues that have been fixed:

  1. If the absolute filepath you were copying had additional periods in it (eg /Users/John.Doe/test.txt), the Tree View would interpret the file to be pasted as /Users/John0.Doe. This would usually fail (for pretty obvious reasons, you're trying to create a new user), especially on Windows.
  2. If the file you were copying did not have an extension (eg test), the pasted file would be test0.undefined because the extension was undefined, and Tree View didn't care.

The fix for 1) involved moving away from .split() and switching to a similar regex that captures only the last period instead of the first. This naturally led to 2): by adding a check to make sure there are no file separators after the period, the captured regex will always be undefined if the filename doesn't have an extension. Tree View now detects this and acts appropriately.

This somewhat addresses #581 in that the last extension will no longer be stripped as per 1). HOWEVER, the second-to-last extension and not the true filename will have the file counter appended to it: style.min.css -> style.min0.css. On the other hand, #397 (which I just realized #581 is a duplicate of) is asking for the functionality implemented in this PR. 😕
This PR now fixes #581 in the manner requested which I feel is more natural than #397.

Specs might take me a while. I'll see what I can do.

Fixes #464, fixes #648, fixes #581, closes #397

Comment thread lib/tree-view.coffee Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially tried to use an extended regex pattern here (the /// provided by Coffeescript), but that led to some nasty escaping issues with #{path.sep} because apparently interpolation happens before the regex is parsed.

@prrrnd

prrrnd commented Dec 8, 2015

Copy link
Copy Markdown

+1, came here to report the issue when copying/pasting files with dots in their absolute path.

@winstliu

winstliu commented Dec 8, 2015

Copy link
Copy Markdown
Contributor Author

Hmm, that reminds me that I still need to add specs to this.

@hedefalk

Copy link
Copy Markdown

+1.

This also happens for me when trying to copy the file

~/.teamocil/sj.yml

Instead of getting

~/.teamocil/sj.0.yml

I get another folder and a file without extension:

~/0.teamocil/sj

This on 1.3.3. Pretty please, can this be fixed into master?

@winstliu

Copy link
Copy Markdown
Contributor Author

Pretty please, can this be fixed into master?

I still need to fix the specs.

@winstliu winstliu closed this Feb 1, 2016
@winstliu
winstliu deleted the wl-paste-fixes branch February 1, 2016 20:27
@winstliu
winstliu restored the wl-paste-fixes branch February 1, 2016 20:30
@winstliu winstliu reopened this Feb 1, 2016
@winstliu

winstliu commented Feb 1, 2016

Copy link
Copy Markdown
Contributor Author

Deleted the wrong branch by accident... 😟

@winstliu

winstliu commented Feb 2, 2016

Copy link
Copy Markdown
Contributor Author

The remaining specs are severely stumping me, but I'm probably just missing something really obvious.

When run normally through the specs window, $(treeView.roots[0].entries).find('.directory:contains(test\\.dir)') fails to find anything. However, if I set a breakpoint and run the exact same code in the console, a match is found and the test passes (even though I didn't assign it to anything)? 😕

Anyone have any ideas?

@winstliu

Copy link
Copy Markdown
Contributor Author

Specs might take me a while.

A while being 6 months 😆...😦. The new specs now pass on my machine - just waiting on Travis to confirm that they're good to go ⌚ ⏳.

I also decided to go with #581 and not #397 as the base filename should always be incremented and not any of the extensions.

I'm worried about the regex performance though - matching long filenames takes a considerable number of steps (147 for C:\Users\John.Doe\Documents\Github\atom\tree-view\lib\test.min.js), and rejecting filenames without extensions takes more than 10x as many steps. I'll try finding a cleaner way, but for now, this is ready for review! 🎉

@atom/feedback

@winstliu winstliu mentioned this pull request Mar 31, 2016
@winstliu winstliu mentioned this pull request May 2, 2016
6 tasks done
@as-cii
as-cii merged commit bbfb926 into master May 17, 2016
@as-cii
as-cii deleted the wl-paste-fixes branch May 17, 2016 07:22
@as-cii

as-cii commented May 17, 2016

Copy link
Copy Markdown
Contributor

Thanks, @50Wliu!

@Ajedi32

Ajedi32 commented Jul 8, 2016

Copy link
Copy Markdown

Fixes #674

@winstliu winstliu mentioned this pull request Jun 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

6 participants