klembot / twinejs

Twine, a tool for telling interactive, nonlinear stories
https://twinery.org
GNU General Public License v3.0
2k stars 296 forks source link

Tab indents in the passage/code editor are auto-indented as spaces #1290

Open NathanMeyers42 opened 2 years ago

NathanMeyers42 commented 2 years ago

Describe the bug.

Not sure if this would be better described as a bug or a feature request because I'm not sure if this is the intended behavior or not, but either way its not ideal.

Pressing tab creates a hard tab which is then auto-indented on subsequent lines as four spaces instead of a tab.

Steps to reproduce:

In the passage editor, press tab, then enter.

Expected behavior:

Tab indents should be auto-indented on subsequent lines as hard tabs.

ALTERNATIVELY

Pressing tab should insert four spaces rather than a hard tab. Pressing backspace while the cursor is on an indent should then delete four spaces instead of one (treating the group of spaces as a single soft tab).

Additional context on this problem.

No response

Twine version number

2.5.1

Does this problem occur with the web version of Twine or the desktop app?

Desktop app

What operating system does this problem occur on?

Windows

If this problem is occurring with the web version of Twine, what browser does it occur on?

No response

Presubmission checklist

greyelf commented 2 years ago

I don't want to start a single TAB character vs multiple SPACE characters for Indentation war...

But in the case of the web-browser release of the Twine 2.x application I think using a single TAB character would be a better default as there is limited amount of storage space for Twine Projects within the web-browser's LocalStorage, especially if the application is being run locally from the Author's machine because that storage space is share with any other locally run HTML file.

rumorsmatrix commented 1 year ago

I have wildly inconsistent tab/space behavior in the editor (Windows, Chrome, web editor 2.5.1)

Pressing tab from the left margin: inserts 1 tab Open a block element with { Next line is indented with 2 spaces Pressing enter, a new line, indented with 2 spaces Inside a block, pressing tab from the left margin inserts 2 spaces and a tab Pressing enter from that line starts a new line with 2 spaces again.

image

klembot commented 1 year ago

Agree, the problem here is that CodeMirror is autoindenting using spaces but not interpolating the tab key as spaces. I think the easiest solution is to use tabs in all cases.