Backslashes when auto-formatting processes

Hi all,

I’m a huge fan of automatic formatting of code on save and was excited to see that the new language server offers code-formatting as well. The only thing that’s keeping me from using it is how it handles backslashes/line-break-escapes in script blocks. For example, when I take this process declaration:

process BBMERGE {

	tag "${sample_id}"

	errorStrategy { task.attempt < 3 ? 'retry' : 'ignore' }
	maxRetries 2

	input:
	tuple val(sample_id), path(reads1), path(reads2)

	output:
	tuple val(sample_id), path("${sample_id}.merged.preclump.fastq.gz")

	script:
	"""
	bbmerge.sh \
	in1=`realpath ${reads1}` \
	in2=`realpath ${reads2}` \
	out=${sample_id}.merged.preclump.fastq.gz \
	outu=${sample_id}.unmerged.preclump.fastq.gz \
	strict k=93 extend2=80 rem ordered \
	ihist=${sample_id}_ihist_merge.txt \
	threads=${task.cpus}
	"""

}

And save it four times in sequence without making any other changes, the LS will successively add more and more backslashes, resulting in something like this:

process BBMERGE {
	tag "${sample_id}"
	errorStrategy { task.attempt < 3 ? 'retry' : 'ignore' }
	maxRetries 2

	input:
	tuple val(sample_id), path(reads1), path(reads2)

	output:
	tuple val(sample_id), path("${sample_id}.merged.preclump.fastq.gz")

	script:
	"""
	bbmerge.sh \\\\\\\\\\\\\\\\
	in1=`realpath ${reads1}` \\\\\\\\\\\\\\\\
	in2=`realpath ${reads2}` \\\\\\\\\\\\\\\\
	out=${sample_id}.merged.preclump.fastq.gz \\\\\\\\\\\\\\\\
	outu=${sample_id}.unmerged.preclump.fastq.gz \\\\\\\\\\\\\\\\
	strict k=93 extend2=80 rem ordered \\\\\\\\\\\\\\\\
	ihist=${sample_id}_ihist_merge.txt \\\\\\\\\\\\\\\\
	threads=${task.cpus}
	"""
}

Is this a formatting I can turn off with a particular setting in my user settings JSON? Or is there some other way I should be formatting long commands to help the LS format correctly? And more generally, is there now or might there eventually be a way to turn on or off particular lints or formatting rules in the language server, akin to what you can do for Python’s Ruff?

Thanks for your great work and keep it up!

–Nick

Hey!

I also had the same issue, however it’s already been fixed in main of the language-server. I think a patch release just needs to be cut on it and in the VS Code Plugin.

1 Like

Oh excellent! A good reminder on always checking github issues before posting here :slight_smile:

Do you know how frequently releases on main get posted, @emiller? Is this something they do manually each week?

I’ve been meaning to make a patch release this week but we’ve been so busy with post-summit activities that I haven’t had a chance. This formatting bug is particularly annoying, sorry that it has remained for so long. I will try to cut a release today or tomorrow if I have some time.

I think this has been fix now? :tada:

Should be fixed in 1.0.1

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.