Skip to content

Commit

Permalink
Merge pull request #83 from dvinokurov/issue79
Browse files Browse the repository at this point in the history
Fixed error while generating message before creating project from SBT
  • Loading branch information
xeno-by committed May 25, 2013
2 parents 1c9281e + f470a3a commit 76aafe2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dotensime.py
Expand Up @@ -119,7 +119,7 @@ def is_sbt(self, project_root):
return has_sbt_files_in_root or has_project_subfolder

def confirm_sbt(self, project_root):
message = "It looks like " + str(project_root) + " is a home of an SBT project. "
message = "It looks like " + encode_if_unicode(project_root) + " is a home of an SBT project. "
message += "\n\n"
message += "That's great news, because you can have Ensime configuration generated by SBT. "
message += "And even better: this generation can be done automatically by Sublime. "
Expand All @@ -133,7 +133,7 @@ def confirm_sbt(self, project_root):
message += "run Tools > Ensime > Maintenance > Create project from scratch."
message += "\n\n"
message += "Do you wish to proceed?"
return sublime.ok_cancel_dialog(message)
return sublime.ok_cancel_dialog(decode_if_str(message))

def fill_in_dot_ensime_with_pre_sbt_mock_config(self, project_root):
message = ";; Sublime is about to run the following commands:\n"
Expand Down
4 changes: 2 additions & 2 deletions ensime.py
Expand Up @@ -77,7 +77,7 @@ def log_on_ui_thread(self, flavor, data):

def prepare_log_message(self, data):
buffer = "["+str(datetime.datetime.now())+"]: "
buffer += data.strip().encode("utf-8") if isinstance(data.strip(), unicode) else data.strip()
buffer += encode_if_unicode(data.strip())
buffer += "\n"
return buffer

Expand Down Expand Up @@ -482,7 +482,7 @@ def async_req(self, to_send, on_complete = None, call_back_into_ui_thread = None

self.feedback(msg_str)
self.log_client("SEND ASYNC REQ: " + msg_str)
self.socket.send(msg_str.encode('utf-8') if isinstance(msg_str, unicode) else msg_str)
self.socket.send(encode_if_unicode(msg_str))

def sync_req(self, to_send, timeout=0):
msg_id = self.next_message_id()
Expand Down
9 changes: 9 additions & 0 deletions strings.py
@@ -0,0 +1,9 @@
def encode_if_unicode(arg):
if isinstance(arg,list):
return [encode_if_unicode(elem) for elem in arg]
return arg.encode("utf-8") if isinstance(arg, unicode) else arg

def decode_if_str(arg):
if isinstance(arg,list):
return [decode_if_str(elem) for elem in arg]
return arg.decode("utf-8") if isinstance(arg, str) else arg

7 comments on commit 76aafe2

@tompro
Copy link

@tompro tompro commented on 76aafe2 May 27, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit seems to have broken the plugin as it is missing an import statement in ensime.py (from strings import *). So the two new functions in strings.py are not available there.

@xeno-by
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for reporting. Going to revert asap.

@tompro
Copy link

@tompro tompro commented on 76aafe2 May 27, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is just a single line missing. My system worked after adding the import statement to ensime.py.

@xeno-by
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please check now?

@tompro
Copy link

@tompro tompro commented on 76aafe2 May 27, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, works perfectly well now. Thanks for the quick response.

@xeno-by
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@dmytro-vynokurov
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that was my fault. Probably missed the import statement while rebasing.
Thank you

Please sign in to comment.