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

Can't "copy" out of CodeMirror buffer (Firefox 40, Linux, jsbeautifier.org) #3486

Closed
Pointy opened this issue Aug 27, 2015 · 15 comments
Closed

Comments

@Pointy
Copy link

Pointy commented Aug 27, 2015

Though it's something I could do in the past, I cannot now copy the contents of the jsbeautifier CodeMirror box. Well, the copy operation doesn't explode or obviously fail, but all that (apparently) gets copied into the system buffer is a "-" character. It doesn't matter where I try and paste; it's like the copy operation is just doing completely the wrong thing.

Copy/paste on the same machine (Ubuntu 15.04) generally works otherwise, in Firefox and elsewhere. For example, I can copy this text out of the GitHub input block and paste it back.

I can copy this text out of the GitHub input block and paste it back.

@vincentwoo
Copy link
Contributor

Can you copy/paste text out of one of the demo CodeMirror pages? Say, http://codemirror.net/mode/javascript?

@Pointy
Copy link
Author

Pointy commented Aug 28, 2015

Yes, that works, darn it :) (Of course I wish it wouldn't, because I completely understand that I'm like some kind of special snowflake here.)

I'm trying everything I can think of to diagnose what's going on; I apologize for burdening this project with this issue, so if it seems bogus or impossible then feel free to close it with extreme prejudice. I've been having this problem only for a short while - I have used jsbeautifier quite extensively for many years with essentially the identical setup I've got now. Thank you for paying enough attention to ask these questions in fact.

@vincentwoo
Copy link
Contributor

It's going to be hard to help you unless you can point us at a particular page that causes the problem for you. jsbeautifier has potentially modified their editor, and they seem to be on an old version of CM (3.11). Perhaps you should file an issue with them, if it's reliably reproducible?

@Pointy
Copy link
Author

Pointy commented Aug 28, 2015

You're probably right. Thanks for your time; I assure you that I completely understand.

@Pointy
Copy link
Author

Pointy commented Sep 1, 2015

For whatever it's worth: I'm finding that I can successfully copy out of the CodeMirror buffer on the jsbeautifier site, but only up to exactly 1000 characters worth. If I select 1001 characters or more, all I get when I try to paste elsewhere (into any other application) is a single "-" character.

Note that to get more than 1000 characters into the jsbeautifier site in the first place, I successfully cut-and-pasted that much text out of a StackOverflow page and into the jsbeautifier page, without incident. It's only copying back out, and only from jsbeautifier, that I'm seeing the problem.

Of course I realize that this may have absolutely nothing to do with CodeMirror. However, when I use the "plain textarea" version of jsbeautifier, everything works fine.

@marijnh
Copy link
Member

marijnh commented Sep 1, 2015

This does have to do with CodeMirror. Are you pasting using the regular clipboard, or X windows' middle-mouse-button behavior?

@Pointy
Copy link
Author

Pointy commented Sep 1, 2015

I'm using Ctrl-C to copy out of the page, so not the simple X selection buffer. (I haven't tried using the Firefox right-mouse menu to copy, I don't think, but I can do that.)

@Pointy
Copy link
Author

Pointy commented Sep 1, 2015

Oh wait, sorry, you asked how I was pasting the clipboard. I'm using Ctrl-V or the right-mouse "Paste" button. I've tried a variety of X applications in addition to Firefox and all behave exactly the same way.

@marijnh
Copy link
Member

marijnh commented Sep 2, 2015

So jsbeautifier appears to be on codemirror version 3.11, which is two and a half years old. I am not going to debug issues with ancient versions.

@marijnh marijnh closed this as completed Sep 2, 2015
@Pointy
Copy link
Author

Pointy commented Sep 2, 2015

Completely understand. I'll update the ticket with the js-beautify project.

Thanks for your time spent thinking about this.

@megaroma
Copy link

megaroma commented Aug 3, 2017

I know it is old but
I have absolutely the same problem with sites:
https://codepen.io
http://www.cssportal.com
on Kubuntu 17.04

@AnnanFay
Copy link

AnnanFay commented May 2, 2018

I am having this exact problem trying to copy source code from the Greasemonkey internal editor. I have no idea if this uses CodeMirror, but it's the only reference to a bug like this I could find.

I am running Firefox on base Debian.

@ghost
Copy link

ghost commented Jan 24, 2019

Same exact problem here, Greasemonkey copying stops at 1001 characters. Ubuntu 16

@ghost
Copy link

ghost commented Jan 24, 2019

The offending code is this selection function:

// Reset the input to correspond to the selection (or to be empty,
// when not typing and nothing is selected)
TextareaInput.prototype.reset = function (typing) {
  if (this.contextMenuPending) { return }
  var minimal, selected, cm = this.cm, doc = cm.doc
  if (cm.somethingSelected()) {
    this.prevInput = ""
    var range = doc.sel.primary()
    minimal = hasCopyEvent &&
      (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000)
    var content = minimal ? "-" : selected || cm.getSelection()
    this.textarea.value = content
    if (cm.state.focused) { selectInput(this.textarea) }
    if (ie && ie_version >= 9) { this.hasSelection = content }
  } else if (!typing) {
    this.prevInput = this.textarea.value = ""
    if (ie && ie_version >= 9) { this.hasSelection = null }
  }
  this.inaccurateSelection = minimal
};

@adrianheine
Copy link
Contributor

Have you brought this issue up with Greasemonkey?

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

No branches or pull requests

6 participants