brackets-archive / bracketsIssues

Archive of issues in brackets.
0 stars 0 forks source link

Mac automation can't retrieve selections > 1000 characters #12614

Open core-ai-bot opened 3 years ago

core-ai-bot commented 3 years ago

Issue by unnamedcrewman Thursday Apr 10, 2014 at 19:19 GMT Originally opened as https://github.com/adobe/brackets/issues/7478


I'm on a Mac (OSX 10.9.2) and I have a system service that takes some selected text and appends it to a fixed, existing file on disk. This service performs well in several text editors that I have tries. It used to perform well in Brackets, but after sprint 36 (I think) it is exhibiting some strange behavior. If I select a small amount of text (20 lines at about 80 characters per line), the script works just fine, i.e. the text is appended correctly.

However, if I select more text than that in a single selection, the script only appends a single hypen (-) to the target document. This behavior only shows up with Brackets, unfortunately.

I'm willing to try debugging this further, but I have no real idea where to start. Any thoughts would be appreciated.

core-ai-bot commented 3 years ago

Comment by peterflynn Friday Apr 11, 2014 at 00:42 GMT


@unnamedcrewman Can you give some more detail about this setup?

core-ai-bot commented 3 years ago

Comment by unnamedcrewman Friday Apr 11, 2014 at 05:15 GMT


Apologies for the lack of clarity and missing detail.

I am invoking a system service on OSX, set up through Automator. The service gets the currently selected text in an editor and appends it to a hard-coded text file already existing on the hard drive. I can invoke it through the Services menu of whichever editor I'm using.

This is the python script that is called on the text through the service:

import sys

text = sys.stdin.read().strip()

with open('/Users/username/Dropbox/main/mth107/comments/_cmt.md', 'a') as f:
    f.write(text)

This append process currently works as expected on text selections in Byword, Multimarkdown Composer, Sublime Text 3, Text Wrangler, Nvalt (and I'm assuming any other similar programs). When invoked, any arbitrarily-sized amount of selected text is appended to the _cmt.md file.

When I invoke the service on text selected in Brackets, it works as expected for small chunks of text, but for larger chunks all it does is append a hyphen (-) to the document. For these larger chunks, none of the selected text is appended at all, just the hyphen. I have tested this in Brackets with all the extensions disabled, so I don't think it is an extension causing the problem.

I'm not sure how to tell exactly at what length of string the problem is, but here is a rough test I did.

I took a long string of lipsum and isolated the last character that could be selected and appended properly from Brackets. I saved that to a file, and running the shell command wc -c < test.txt returns 1000 (my understanding is this represents bytes).

Brackets updates and views the appended file just fine, and shows the newly added hyphen the same as all the other editors.

Interestingly, I have another OSX system service that takes currently selected text and sends it to Marked.app ( a Markdown previewer). The same issue shows up for this service also. Any text longer than the 1000 bytes shows up in Marked.app as a single empty bullet list item arising from a single hyphen passed in. Again, this limit only shows up when I invoke the service on selected text in Brackets. Invoking the Marked.app service on text from other editors works as expected for any arbitrarily large amount of selected text.

core-ai-bot commented 3 years ago

Comment by peterflynn Friday Apr 11, 2014 at 18:18 GMT


This appears to be an issue with CodeMirror in general -- I think you'll see the same problem in a demo like this too: http://codemirror.net/demo/theme.html.

The issue is that CodeMirror virtualizes selections over 1000 characters: https://github.com/marijnh/CodeMirror/blob/master/lib/codemirror.js#L2292.

Short of implementing a CodeMirror mode that disables polling and relies only on input events, it might not be possible to work around this. Marking 'move to backlog' to assess what sort of strategy we'd want to take here. There might be larger questions about supporting Mac automation in general, too.

core-ai-bot commented 3 years ago

Comment by peterflynn Friday Apr 11, 2014 at 18:19 GMT


Also, adjusting title to clarify problem (was: "Strange behavior on external file change (appended text)")

core-ai-bot commented 3 years ago

Comment by unnamedcrewman Friday Apr 11, 2014 at 18:27 GMT


Thanks for looking this over. Personally I use this only for markdown prose writing, so I can easily switch to another editor for that. I'll keep an eye on what happens here.

core-ai-bot commented 3 years ago

Comment by MarcelGerber Friday Apr 11, 2014 at 20:32 GMT


FWIW, you can use this extension for preview of .md files as well

core-ai-bot commented 3 years ago

Comment by peterflynn Friday Apr 11, 2014 at 21:38 GMT


@unnamedcrewman Yeah, Brackets is actually great for writing Markdown because you can see a real-time preview of what you're typing the whole time. I highly recommend the extension that@SAPlayer mentioned.

core-ai-bot commented 3 years ago

Comment by unnamedcrewman Friday Apr 11, 2014 at 23:32 GMT


@SAPlayer Thanks for the heads up. I think the real-time preview will be great for most of what I do.

@peterflynn Thanks for changing the title. Much more accurate. Newbieness can't be hidden.

core-ai-bot commented 3 years ago

Comment by peterflynn Monday Apr 14, 2014 at 17:46 GMT


No worries! Sometimes it takes a little investigation to know how much to generalize the description.