Repository navigation
Copy selection command to only write to clipboard if text selected - #8025
Conversation
8e3d306 to
e925735
Compare
There was a problem hiding this comment.
Just wondering why you decided to call copySelectedText() here instead of inlining the part for copying the line? Calling copySelectedText() will cause all selections to be processed again within that function, not just the selection currently being processed within copyOnlySelectedText(), right? While that normally won't be a performance problem, I think avoiding doing the same thing over and over again (since this would be a loop nested within the same loop) is always nice.
I also wonder if calling copySelectedText() here might cause problems in some cases because all selections will be processed according to the rules of that function, and not just by the rules of copyOnlySelectedText()? I'm thinking of cases with multiple selections, where one selection is empty and at the beginning of the line, and the other is empty but not at the beginning of the line.
There was a problem hiding this comment.
@izuzak I decided to use copySelectedText() because I thought reusing code would be nicer than inlining that part, but I hadn't considered that it would process all selections again - so I think you're right - it would be best to avoid doing the same thing twice. I'll make some changes :)
|
cc @maxbrunsfeld for 👀 and 💭 since you were looking at #7103. |
e925735 to
2a3011a
Compare
…he beginning of the line.
2a3011a to
2655513
Compare
There was a problem hiding this comment.
I would think that the maintainClipboard = true statement should be inside of the if not selection.isEmpty() block. Otherwise, if the first selection is empty and the second selection is not, the existing clipboard entry will be mutated unexpectedly.
|
@maxbrunsfeld this PR is now up to date based on your comment |
There was a problem hiding this comment.
I'd actually like to not add this to our public API right now. Could you change Essential -> Private here?
Also, there's a small typo: hightlighted -> highlighted.
Also, I don't think the last sentence of the comment is true; it doesn't look like there's any special behavior of the cursor is at the beginning of the line. Did you intend to implement that behavior? If not, we should just remove that sentence from the comment.
There was a problem hiding this comment.
yeah, in an earlier version of this branch, that comment was true - but then based on some feedback from what I read in the discussion in #7103 I removed it, so it's no longer true. I'll remove that and update the rest
fd49935 to
c38b2c0
Compare
c38b2c0 to
1a965ed
Compare
There was a problem hiding this comment.
Could you remove this second blank line?
|
Other than the placement of two |
|
shoot, sorry about the newlines, i'll make a quick change and push |
d728d8c to
6e00880
Compare
6e00880 to
e96d6f5
Compare
|
Great! |
Copy selection command to only write to clipboard if text selected
|
👏 |
Closes #7103
Add a new command,
editor:copy-selection, that writes to the clipboard only if the user has selected text