Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add atomic tabs option #107126

Merged
merged 7 commits into from
Nov 21, 2020
Merged

Add atomic tabs option #107126

merged 7 commits into from
Nov 21, 2020

Conversation

Timmmm
Copy link
Contributor

@Timmmm Timmmm commented Sep 20, 2020

This treats tabs faked using spaces as if they were real tabs meaning that you can't select the middle of them. I have added a test, with 100% code coverage over the core logic. I've also tested this fairly extensively with hairy mixed-indentation files and with multiple cursors.

There are a few caveats that I need advice with:

  1. I have not used indentSize anywhere (see this comment).

  2. I am not 100% sure I added the new atomicTabs setting everywhere it should be. I basically grepped for insertSpaces and added it in the same places (except a few bits where it didn't make sense). But that is loaaads of places so I might have missed some.

3. There is one bg with the mouse handling that I need advice on (not sure I've intercepted the mouse stuff in the right place). Basically if you just click it's fine, but if you select some text and then click in the selection it won't use the atomically snapped position.

This PR fixes #2798

@ghost
Copy link

ghost commented Sep 20, 2020

CLA assistant check
All CLA requirements met.

@Timmmm
Copy link
Contributor Author

Timmmm commented Sep 20, 2020

Here is a video showing the behaviour, including the outstanding bug.

atomic_tabs2

@rmunn
Copy link
Contributor

rmunn commented Sep 21, 2020

I'd recommend the name "atomic soft tabs" rather than "atomic tabs", as the latter would make some people (including me) think this changed the behavior of tab characters. "Soft tabs" is the usual name, AFAICT, for "hit the Tab key and N space characters get added to the file" feature (where N is, of course, the value of indentSize, because that's what people using a "soft tabs" feature expect to get when they hit the Tab key).

@Timmmm
Copy link
Contributor Author

Timmmm commented Sep 22, 2020

The Mac build failed due to a network failure. Is there any way to run it again other than pushing a dummy commit?

@rmunn
Copy link
Contributor

rmunn commented Sep 24, 2020

Closing and reopening the PR also retriggers build steps, without needing a dummy commit.

@Timmmm Timmmm closed this Sep 24, 2020
@Timmmm Timmmm reopened this Sep 24, 2020
@Cons-Cat
Copy link

Amazing to see this! I was recently surprised to find that it isn't already a core feature, but now I really hope it will be.

@Timmmm
Copy link
Contributor Author

Timmmm commented Sep 26, 2020

Ok this works perfectly as far as I can tell now. Who do I need to bribe to get it reviewed? :-D

Timmmm and others added 3 commits October 11, 2020 13:18
This treats tabs faked using spaces as if they were real tabs meaning that you can't select the middle of them.
@Cons-Cat
Copy link

It's very unfortunate that this isn't receiving the attention it deserves.

@Timmmm
Copy link
Contributor Author

Timmmm commented Oct 19, 2020

@alexdima Any chance of a review?

@alexdima
Copy link
Member

This looks very good! Thank you! ❤️

I just did some changes on top:

  • it's unlucky that you looked for insertSpaces, which is a special kind of editor option, one that lives with the text buffer. I've converted the option to a regular editor option, reducing the changed file count.
  • I pushed a slight optimization to avoid walking the leading whitespace again in case of going left.
  • small stylistic changes

I'm sorry I didn't get to this sooner.

@alexdima alexdima added this to the November 2020 milestone Nov 21, 2020
@alexdima alexdima merged commit fb80c0e into microsoft:master Nov 21, 2020
@Timmmm
Copy link
Contributor Author

Timmmm commented Nov 21, 2020

Amazing, thank you so much!

chenjigeng pushed a commit to chenjigeng/vscode that referenced this pull request Nov 22, 2020
@alexdima
Copy link
Member

alexdima commented Nov 30, 2020

I've renamed the setting to editor.stickyTabStops since we already had a setting called editor.useTabStops to control the behaviour of backspace / delete for the spaces in the indentation and the feedback from the team was that "atomic" and "soft tabs" were new terms that they didn't hear before.

@Timmmm
Copy link
Contributor Author

Timmmm commented Dec 1, 2020

I copied it from Atom

image

I thought it was a decent enough name - atomicTabStops would be fine too. Atomic in the sense that the tabs can no longer be split.

I'm not sure I understand sticky. Isn't sticky for things that stick? Like a sticky menu that sticks to the top of your screen. Are you thinking that the cursor sticks to the tab stop?

Anyway you guys are the bosses - not really too bothered what it is called as long as it exists! :-D

By the way I made a little video to demo it, in case you want something for the release notes.

@Timmmm
Copy link
Contributor Author

Timmmm commented Dec 1, 2020

Demo video:

atomic_tabs.mp4.zip

@github-actions github-actions bot locked and limited conversation to collaborators Jan 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Navigate Soft Tabs As If They Are Hard Tabs
4 participants