Opened 5 years ago

Closed 5 years ago

#1848 closed defect (fixed)

Editor in Scaffold should use tabs rather than spaces

Reported by: simon Owned by: ajlyon
Priority: major Milestone: 2.1 Final
Component: scaffold Version: 2.1
Keywords: Cc: ajlyon

Description

or at least spacing should be consistent in the translators it creates

Change History (5)

comment:1 Changed 5 years ago by ajlyon

  • Cc ajlyon added
  • Owner changed from simon to ajlyon
  • Status changed from new to accepted

Are you referring to the spacing of JSON output? I know that we frequently mess up the blame log for the JSON headers of translators, but that part is in Zotero's core translator saving code. Some of the issues recently are because I'm using MLZ + Scaffold, which until recently was using spaces.

If you're referring to the indentation that ACE gives us, we can probably modify it pretty easily. It's now producing spaces, and you'd prefer tabs?

comment:2 Changed 5 years ago by simon

I changed translator.js on the trunk to use tabs for the JSON in r9629, but that's not what I find particularly bothersome.

What's more problematic is that since most translators (and all Zotero core code) use tabs but ACE uses spaces, editing a translator in Scaffold results in mixed indenting. I'd prefer that ACE indent with tabs instead of spaces. For bonus points, Scaffold could normalize spaces -> tabs with a regexp on load.

comment:3 Changed 5 years ago by ajlyon

The ACE setting is fixed in https://bitbucket.org/ajlyon/scaffold/changeset/4413fd9c4647 and in the most recent build of Scaffold at http://www.gimranov.com/research/zotero

If you can recommend a reasonable regex for normalization, or a patch, we can normalize tabs on load. Somehow, I think that s/ {4}/\t/g won't do it, but maybe I'm mistaken.

comment:4 Changed 5 years ago by simon

For the case of \t = 4 spaces:

function normalizeWhitespace(text) {
	return text.replace(/^[ \t]+/gm, function(str) {
		return str.replace(/ {4}/g, "\t");
	});
}

I think this would be sufficient. A more sophisticated algorithm would attempt to detect \t = 2 spaces, etc. but if there are translators with spacing like that, we can just correct them manually.

comment:5 Changed 5 years ago by ajlyon

  • Resolution set to fixed
  • Status changed from accepted to closed

Fixed in bitbucket (https://bitbucket.org/ajlyon/scaffold/changeset/d847789de18a). I'll merge all this back to subversion soon.

And I didn't realize that replace could take a callback as the second argument. That makes things a lot easier.

Note: See TracTickets for help on using tickets.