Skip to content

Commit

Permalink
fix completion after dot after closing brace )
Browse files Browse the repository at this point in the history
  • Loading branch information
phil294 committed May 21, 2022
1 parent 23d7238 commit d02fddf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/src/services/transpileService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ const try_translate_coffee = (coffee_doc: TextDocument): ITranspilationResult =>
// Still need the `𒐩` to detect the fake js line further below
if(try_fake_line_compilation(
(coffee_error_line
.substring(0, coffee_error_line.length - end.length) + '𒐩'
.substring(0, coffee_error_line.length - end.length) + '.𒐩'
).trim())) {
fake_line_mechanism = 'modified_js'
fake_line_modified_js_end_removed = end
Expand Down Expand Up @@ -339,9 +339,9 @@ const try_translate_coffee = (coffee_doc: TextDocument): ITranspilationResult =>

} else {
const fake_js_line = js_fake_arr[js_fake_𒐩_line_no]!
const 𒐩_index = fake_js_line.indexOf('𒐩')
const 𒐩_index = fake_js_line.indexOf('.𒐩')
const before_𒐩 = fake_js_line.slice(0, 𒐩_index)
const after_𒐩 = fake_js_line.slice(𒐩_index + 2) // 2 because 𒐩 is 2 chars in size?? Hopefully this is stable
const after_𒐩 = fake_js_line.slice(𒐩_index + 3) // 𒐩 is length 2
let tail = ''
if(after_𒐩 !== ';') {
// This is not really expected but can sometimes happen when fake line is being
Expand Down
4 changes: 4 additions & 0 deletions test/lsp/features/completion/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,8 @@ describe('Should autocomplete', () => {
it('does not mess up indent in modified-js', async () => {
await testCompletion({ doc_uri: getDocUri('completion/modified-js-indent.coffee'), position: position(2, 35), expected_items: ['modified_js_indent_prop'] })
})

it('completes after dot after closing brace', async () => {
await testCompletion({ doc_uri: getDocUri('completion/dot-after-closing-brace.coffee'), position: position(1, 14), expected_items: ['splice'], allow_unspecified: true })
})
})
2 changes: 2 additions & 0 deletions test/lsp/fixture/completion/dot-after-closing-brace.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
aaa = ([]
.sort =>).

0 comments on commit d02fddf

Please sign in to comment.