vscode-scala-syntax icon indicating copy to clipboard operation
vscode-scala-syntax copied to clipboard

Autoclosing Single Quote in Macro Programming

Open kkdaisuki opened this issue 2 years ago • 1 comments

Hello!

I am working on some macros recently on VS Code. Nevertheless I find it quite bothering that whenever I try to create a quoted expression, the plugin automatically closed it for me. A simple example,

def concatImpl(a: Expr[String], b: Expr[String])(using Quotes): String =
  a.valueOrAbort + b.valueOrAbort

inline def concat(a: String, b: String)(using Quotes): String = ${ concatImpl('...'...) }
//                                                                                ^
//                                            A single quote is automatically created here by the plugin during editing

It seems that language-configuration.json defines single quote to be one of the autoclosing pairs. Removing it would certainly solve this problem, but it may also impact the user experience of the users without the need to use macros. What do you think?

kkdaisuki avatar Jun 16 '23 14:06 kkdaisuki

We might also use the notIn guard.

nicolasstucki avatar Jun 16 '23 15:06 nicolasstucki

I don't think notIn can help here. If I understand the syntax correctly after an single ' it's unkown if we want to contiue with a charater literal or a quote.

val incomplete = '
val singlechar = 'a'
val marcoquote = '{ 1 }

Jentsch avatar Oct 08 '24 10:10 Jentsch

We stopped adding the second ' as it proved to be a problem here and overall not a great improvement over just typing it normally

tgodzik avatar Oct 09 '24 13:10 tgodzik