configuration: allow `tab` to insert spaces at the end of a line
Describe the bug
Apologies in advance if this is better highlighted as a feature request.
I would like the ability to enter tab to insert and align spaces after a line, as in the case of formatting inline comments:
def foo(bar):
barbar = bar * 2 # doubles bar
print(f'{bar} -> {barbar}') # print barbar
return barbar
Environment
{
"marimo": "0.8.15",
"OS": "Darwin",
"OS Version": "23.5.0",
"Processor": "arm",
"Python Version": "3.11.9",
"Binaries": {
"Browser": "128.0.6613.138",
"Node": "--"
},
"Dependencies": {
"click": "8.1.7",
"importlib-resources": "missing",
"jedi": "0.19.0",
"markdown": "3.7",
"pygments": "2.16.1",
"pymdown-extensions": "10.9",
"ruff": "0.6.4",
"starlette": "0.38.4",
"tomlkit": "0.13.2",
"typing-extensions": "4.12.2",
"uvicorn": "0.30.6",
"websockets": "12.0"
},
"Optional Dependencies": {
"pandas": "2.1.0"
}
}
Code to reproduce
No response
I think this is more of a feature request - as I can see both being preferences.
Do you use a formatter? Does your formatter handle this (or undo this)?
Actually this might be a bug - seems like the tab logic is being intercepted by: https://github.com/marimo-team/marimo/blob/33d862b596085c6729015c41649c4fed43ef2197/frontend/src/core/codemirror/cm.ts#L97-L109
cc @akshayka
Is a completion accidentally being triggered?
EDIT: okay I think I understand. I can take a look.
@jydiw - there was a bug in the existing code, which i have fixed here: https://github.com/marimo-team/marimo/pull/2394
The logic is still:
- if you are at the end of the line, it will try to open the autocomplete
- if you are in the beginning or middle, it will insert 4 spaces.
Is this ok for your use-case? If you are trying to insert the tab/spaces between you code and an inline-comment, this would work. But if you are trying to add a tab at the end of the line, this won't solve that case. Do you still hope for this to be configurable for that case?
Sorry @jydiw - scratch what I saw. I think we plan on keeping Tab as completion anywhere in the line (not just the end). So we can keep this as a FR to make it configurable.
I am coming from VSCode so perhaps this request is only because of what I am used to. Its behavior is slightly different than what you describe:
- If you are at the beginning of a line, it will insert {tabwidth} spaces.
- If you are anywhere else, it will insert however many spaces needed to get to the nearest multiple of {tabwidth}.
# if i type this sentence < tab inserts to here
# and if i type this one < tab also inserts to here