hax / atom-elastic-tabstops

Elastic Tabstops for Atom
MIT License
84 stars 1 forks source link

My advice to fix the up/down arrows and other stuff #18

Closed RobertBColton closed 7 years ago

RobertBColton commented 7 years ago

Look into the virtual white space that's used to implement rectangle select in Visual Studio. The text editor just acts like there's a space there even if the line is empty. I believe it's how Atom implements rectangle select too. Surprisingly virtual white space is what is still lacking from Visual Studio Code's rectangle select. This might be a good way to fix some of your problems, just thought I'd share.

Perhaps see the Visual Studio extension for elastic tab stops: https://www.alwaysaligned.net/

hax commented 7 years ago

Sorry, I'm not sure what virtual white space mean. And Atom seems not have rectangle select though there are some plugins like https://atom.io/packages/Sublime-Style-Column-Selection and https://atom.io/packages/select-rectangle .

lillem4n commented 7 years ago

Worth to dig in a bit more on? It would be great to have the up and down arrow issue resolved, even if it is not critical. :)

RobertBColton commented 7 years ago

Virtual white space makes an editor "act" like everything is a space. So say you hit enter twice and leave a line with no text on it, in Visual Studio you can still move your cursor through it. It does this for example when you hit enter after typing a function so it can properly indent your cursor, but it doesn't actually add the leading spaces/tabs until you start typing the next line. It's very intelligent how it works and a lot of people adore the feature. So since it lets you place the cursor anywhere there is no text/space/or anything it fixes this up/down issue by letting you place the cursor in the middle of a tab character.

Perhaps Microsoft's blog would be better at explaining it than me: https://blogs.msdn.microsoft.com/zainnab/2010/02/28/understanding-virtual-space/ https://msdn.microsoft.com/en-us/library/aa232417(v=vs.60).aspx

If you still do not understand, I implore you to test this virtual space feature yourself in Visual Studio.

Atom is capable of it: https://discuss.atom.io/t/virtual-space/15603

hax commented 7 years ago

As the last post of https://discuss.atom.io/t/virtual-space/15603

is just «generated spaces», not the True™ virtual space

Real elastic tabstops should not use "generated spaces" method. For example, my current implementation already allow non-monospace fonts which is never possible by "generated spaces".

I think the proper solution for up/down issue is find the Atom internal mechanism to position the cursor which I do not have enough time to investigate. Hope someone could help.

Anyway, as https://github.com/hax/atom-elastic-tabstops/issues/15#issuecomment-305411827 I would like to rewrite this plugin (and hopefully solve up/down issue) after Atom 1.19.x be stable.

RobertBColton commented 7 years ago

Hey, if I get the time, I'll try to dig into Atom some more and help out here.

hax commented 7 years ago

After 2 full days work, the new 1.2.0 version override the editor.moveUp/moveDown behavior which keep the vertical position. Please have a try!

If you want the original moveUp/moveDown behavior, use alt-up/alt-down. There is also a package settings which can swap the behavior.