Monday, March 4, 2013

Ace Cut and Paste

‹prev | My Chain | next›

Up today, I continue working through as many issues as possible before the next chapter of 3D Game Programming for Kids goes up for beta. Last night I took care of the specific issues that absolutely had to get done before the next chapter goes out. Tonight, I start with the the most bothersome of the open issues: cutting and pasting seems to be broken in the in-browser editor that I am using.

It is quite perplexing as copying and pasting works. Cutting text works as well. But, for whatever reason, trying to paste text that was cut in the editor fails silently. I am using
ACE code editor as the editor in my fork of Mr Doob's code editor—presumably I have done something wrong with the configuration.

Or maybe not. After a bit of more in depth investigation, I find that cut text is copied to my clipboard—I can both see it in my clipboard manager (clipit) and can paste it into other applications. I just can't paste it back into ACE. And after even more experimentation, I find that I can restore cut and paste by disabling my clipboard manager entirely. This also seems to be a Chrome-only bug as cut and paste works fine in Firefox.

I spend some time fiddling with the various Ace properties that I have set, but none seem to have an effect. Similarly, exploring the callbacks available to the ace editor:
var editor = ace.edit("editor");
// ...

editor.on('cut', function(cut) {
  console.log('[cut]' + cut)
  console.log(cut)
  console.log(cut.toString())
});
That proves of limited use:
[cut]Range: [0/0] -> [1/0] editor.js:78
Range {start: Object, end: Object, type: "cut", stopPropagation: function, preventDefault: function…}
 editor.js:79
Range: [0/0] -> [1/0] 
In other words, it is definitely cutting, but something is going wrong down the line.

I could chalk this up to a local-only problem. But other Ace installations (e.g. GitHub) do not seem to suffer from this problem. This bothers me enough that I will likely give it another go tomorrow. Having seemingly exhausted the things that I can try in my current setup, it seems as though I need to revisit this starting from scratch with a basic case rather that trying to troubleshoot with all of the other code-editor stuff going on.

Day #680

No comments:

Post a Comment