Artawower / turbo-log

Fast log message inserting for quick debug.
79 stars 5 forks source link

Support for Ecmascript without semicolons #3

Closed ktfleming closed 3 years ago

ktfleming commented 3 years ago

Cool package! Do you think it's possible to support the semicolon-less style, as found in Standard, for example? Currently if I have

function test() {
  const foo = 1
  const bar = 2
}

and I select the const foo = 1 line and run M-x turbo-log-print, I get

function test() {
  const foo = 1
  const bar = 2
}console.log('[line 3][*js*] TCL:  const foo = 1: ', foo);
Artawower commented 3 years ago

Hello, thanks for the remark! I am aware of this problem, now it is happening because there are various complex cases of carriage position, like this (when your try to select name for example)

function testFuncWithBigSignature(
  name: string,
  age: number,
  patronymic?: string,
): string {
  return `${name} is ${age} years old.`
}

But now I will use a stack to count the pairwise brackets to better determine the insertion position, and I hope it will help solve this and similar problems.

Artawower commented 3 years ago

It should be better now. Also I added support for disabling semicolon for console log, your can configure it with (plist-put turbo-log--ecmascript-configs :include-semicolon nil) 😊

ktfleming commented 3 years ago

Looks like it's working fine, thanks for the quick improvement!