Cacodaimon / GhostText-for-Chrome

GhostText Chrome extension
12 stars 5 forks source link

Either allow typing in Chrome when the connection is open, or disable the textarea until it's disconnected #9

Closed fregante closed 10 years ago

fregante commented 10 years ago

Right now it seems that once the connection is open, if I type in the textarea, any key will replace the entire content.

I would be best to allow two-way synchronization, but if that's too hard, I'd suggest making it <textarea readonly>.

If we go with the latter, a click on the read-only textarea should enable it and close the connection. Before we do that we should implement #6 so that the user knows that the connection has been closed.

Cacodaimon commented 10 years ago

I think it's a problem with the selection/cursor if the selection is disabled everything work fine on both sides:

var minMaxSelection = GhostText.getMinMaxSelection(response.selections);
//textAreaDom.selectionStart = minMaxSelection.start;
//textAreaDom.selectionEnd   = minMaxSelection.end;

Maybe the live selection has just to be disabled since it is causing more trouble without any benefit?

fregante commented 10 years ago

You're right about the lack of benefits (except that it's cool). It's strange that the behavior is only there until you type something in ST, then it works normally.

Cacodaimon commented 10 years ago

I made a quick fix, when sublime text now receives a text change the cursor will be set to the end of the text in ST self.view.sel().add(sublime.Region(text_length, text_length)) this fixes this strange behavior since sublime text seems to select the whole text when the views contents gets replaced…

Now it's working and we have still this coll live selection effect :smile: .