Skip to content

Commit

Permalink
Merge pull request #23 from Dan2552/symbols
Browse files Browse the repository at this point in the history
Symbols
  • Loading branch information
Dan2552 committed May 21, 2017
2 parents 93fe78e + 8b6392a commit d24f1a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/source_kitten.py
Expand Up @@ -19,11 +19,13 @@ def complete(offset, file, project_directory, text):
text = _cut_calculated_offset_difference(offset, calculated_offset, text)
source_files = _source_files(file, project_directory)

offset_in_bytes = _calculate_offset_in_bytes(calculated_offset, text)

cmd = [
_sourcekitten_path(),
"complete",
"--text", text,
"--offset", str(calculated_offset),
"--offset", str(offset_in_bytes),
"--",
"-j8"
] + _sdk_and_target() + source_files
Expand Down Expand Up @@ -170,6 +172,9 @@ def _cut_calculated_offset_difference(offset, calculated_offset, text):
right = text[offset:len(text)]
return left + right

def _calculate_offset_in_bytes(length_offset, text):
return len(text[0:length_offset].encode('utf-8'))

def _create_temp_file(text):
path = temp_file_path()
with open(path, "w") as text_file:
Expand Down
10 changes: 10 additions & 0 deletions test/source_kitten_test.py
Expand Up @@ -153,4 +153,14 @@ def test_cursor_info_unsaved(self):

self.assertEqual(output["key.name"], "consumedBananaz")

# Issue raised by GitHub user @ccampbell
# https://github.com/Dan2552/SourceKittenSubl/issues/19
def test_copyright_symbol(self):
file = ""
text = "// ©©\nvar test = 10\ntest."
offset = len(text)
project_directory = "/dev/null"
output = source_kitten.complete(offset, file, project_directory, text)

self.assertTrue(len(list(output)) > 0)
self.assertEqual(output[0]['sourcetext'], "advanced(by: <#T##Int#>)")

0 comments on commit d24f1a3

Please sign in to comment.