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

Folded code unfolds if you spend some (unknown number) of ms idle in a fold #1004

Open
phrohdoh opened this issue Oct 27, 2016 · 73 comments
Open

Comments

@phrohdoh
Copy link

phrohdoh commented Oct 27, 2016

  • Click thumbs-up 👍 on this issue if you want it!
  • Click confused 😕 on this issue if not having it makes VSCodeVim unusable.

The VSCodeVim team prioritizes issues based on reaction count.


What did you do?

Scrolled through folded code once with the j key held down, another time pressing it over and over.

What did you expect to happen?

Folded lines were skipped.

What happened instead?

Cursor did not skip the folded lines (watch the line numbers in the gif).

Technical details:

  • VSCode Version: 1.6.1
  • VsCodeVim Version: 0.4.0
  • OS: macOS Sierra (10.12)

vscode-vim-skip-folds

@johnfn
Copy link
Member

johnfn commented Oct 27, 2016

This is annoying, but also hard. @aminroosta tried but had a bad time: #708

The problem as I understand it is that the only API VSCode allows us is "cursorMove" to move the cursor over folded lines, but we would actually like to know the position of the cursor as well (which "cursorMove" does not provide).

@ta3pks
Copy link

ta3pks commented Oct 28, 2016

on ubuntu, i also suffer from this a log I found the solution using gg to jump to the last line

@phrohdoh
Copy link
Author

phrohdoh commented Nov 1, 2016

gg takes you to the first column on the first row, not the last line.

@ta3pks
Copy link

ta3pks commented Nov 1, 2016

@phrohdoh for example 25gg will take you to 25th line not the beginning i meant end of the block by last line

@phrohdoh
Copy link
Author

phrohdoh commented Nov 1, 2016

@NikosEfthias Oh I see, TIL. Thanks!

@exhuma
Copy link

exhuma commented Feb 23, 2017

I can confirm this on VSCode 1.9.1 with Vim Plugin 0.5.3.

This makes working with larger, more complex files very unwieldy!

I've tried disabling the vim plugin and moving with the cursor keys. In that case it works as expected (folds remain closed).

@skawaii
Copy link

skawaii commented Mar 2, 2017

+1 for this. Having my folds open while I'm navigating is quite frustrating. I find myself having to use my mouse to reposition my cursor, which should make all of us sad.

@zwing99
Copy link

zwing99 commented Mar 7, 2017

+1 for fixing this asap

@ztmdsbt
Copy link

ztmdsbt commented Mar 7, 2017

+1 for this. It makes me very painful.

@phrohdoh
Copy link
Author

phrohdoh commented Mar 7, 2017

+1 comments aren't going to do anything but annoy the repo owners.
Please use the 👍 reaction on the original post instead.
Be kind to repo owners and other subscribed users.

@phrohdoh phrohdoh closed this as completed Mar 7, 2017
@phrohdoh
Copy link
Author

phrohdoh commented Mar 7, 2017

Oops now I'm spamming (I didn't mean to close this).

@phrohdoh phrohdoh reopened this Mar 7, 2017
@johnfn
Copy link
Member

johnfn commented Mar 7, 2017

:) It's okay. We generally use thumbs up as a measure of importance, but the extra signal we get from people who were so bothered they had to come and leave a comment is a little useful too. We're definitely aware this one is painful - we'll try to fix it as soon as we can!

@johnfn
Copy link
Member

johnfn commented Mar 9, 2017

Investigated this and realized it required some help from VSCode. Opened up an issue over there: microsoft/vscode#22276

@calebmeyer
Copy link

Related: microsoft/vscode#25097

Glad to hear I'm not the first one to experience it.

@equinoxr
Copy link

sorry to say, but this makes the extension useless for me.

greetz...

@Chillee
Copy link
Member

Chillee commented May 16, 2017

I polished up my fix over here: #1552

It does some hackish stuff, but it seems to work great for me. Here's a pretty bad demo:

test

Chillee added a commit that referenced this issue May 21, 2017
Fixing the automatic fold expansion (#1004)
@Chillee
Copy link
Member

Chillee commented May 25, 2017

We just pushed out a new version, so enable vim.foldfix and tell us what you think!

It's a hack and not a proper solution to this problem, so we'll probably leave this issue open for now.

@Wojnach
Copy link

Wojnach commented Oct 21, 2019

The j to gj bind is undesireable, IMO. gj won't "remember" which column you were at when pass an empty line.

gj will result in:
line 1: column 45
line 2: column 0 (empty line)
line 3: column 0

j will result in:
line 1: column 45
line 2: column 0 (empty line)
line 3: column 45

@gveneyjr
Copy link

gveneyjr commented Nov 1, 2019

with foldfix it works with j/k, but

  • ctrl-u/ctrl-d
  • {/} (shift-[/shift-])
  • 10-/10+ (relative jump)

still open collapsed fold.

As an alternative to CTRL-u & CTRL-d I've been using H & L which do not break the fold.

@aerosayan
Copy link

I was really liking the feel of vscode.
However, when I saw this issue pop up for me, it was really problematic.
I saw many of your discussions on this topic with the moderators of vscode.
And I think you're absolutely right to ask for a better API.

I really appreciate the work this project's contributors have done.

Not being able to scroll past folded regions in vim mode makes vscode useless to me.
And since vscode isn't able to provide the requested features that you all requested, I am leaving vscode behind.

QtCreator would be my preferred IDE for the time being.

Thank you all for your hard work.

@benyaminl
Copy link

We just pushed out a new version, so enable vim.foldfix and tell us what you think!

It's a hack and not a proper solution to this problem, so we'll probably leave this issue open for now.

Can you make this a default option, not everyone know about this, I just want to open an issue then when I search again on google, finally I landed on this, or at least the issue should be pinned down.

Thank you for brigging the foldfix, I really frustated with how the cursor open all fold

@mattiaspalmgren
Copy link

As an alternative to CTRL-u & CTRL-d I've been using H & L which do not break the fold.

To add on this, you can use the following settings to make it more jump like:

"vim.normalModeKeyBindings": [
      {
        "before": ["<C-u>"],
        "after": ["H", "z", "z"]
      },
      {
        "before": ["<C-d>"],
        "after": ["L", "z", "z"]
      }
]

@J-Fields
Copy link
Member

J-Fields commented Mar 1, 2020

@scutxd Could you please file a separate issue?

@bushnerd
Copy link

bushnerd commented Mar 1, 2020

@scutxd Could you please file a separate issue?

OK. Thank you.

@yunti
Copy link

yunti commented Jun 8, 2020

does anyone know how to rebind up and down arrow to gj gk? Occasionly I go back to the old way, using arrow keys and it breaks the fold and it's quite frustrating.

currently I have, which only works for the j , k remap: (upArrow downArrow seem to be wrong, UpArrow and DownArrow don't seem to work either. )

"vim.normalModeKeyBindingsNonRecursive": [
    {
      "before": ["j"],
      "after": ["g", "j"]
    },
    {
      "before": ["k"],
      "after": ["g", "k"]
    },
    {
      "before": ["downArrow"],
      "after": ["g", "j"]
    },
    {
      "before": ["upArrow"],
      "after": ["g", "k"]
    },
}

@DevotionGeo
Copy link

I have only "vim.foldfix": true, in my settings and it works fine, both with j, k and upArrow, downArrow.

@desprit
Copy link

desprit commented Jul 7, 2020

Not sure why it has been closed because ctrl+d and ctrl+u still unfolds the code.

@J-Fields my bad, it's a linked issue that is closed, not the actual ticket

@J-Fields
Copy link
Member

J-Fields commented Jul 7, 2020

@desprit The issue isn't closed. As far as I know (it's been a while since I've looked into this very closely), there's nothing we can do unless VSCode expands its API to give us more information about folded regions.

@Chillee
Copy link
Member

Chillee commented Jul 7, 2020

@benyaminl foldfix is some extremely hacky code I wrote a long time ago. I am far too ashamed of it to ever want it to be enabled by default :)

@zwing99
Copy link

zwing99 commented Jul 7, 2020

I agree with @Chillee . Maybe some one should reopen the issue with vscode? It has been a couple of years maybe it can be prioritized.

@peey
Copy link

peey commented Jul 20, 2020

@J-Fields I'd like to open a feature request on VSCode, but I think to make it effective they will need communication from you on what API surface do you really need to support this feature.

Could you provide a technical overview of (1) how you currently handle folds in this extension, (2) what actually triggers this issue, and (3) what would you need to fix it?

My best guess is that you don't know if there is a 5-line fold on say line 10, so when I press j you're telling VSCode to go to line 11 but actually if you had that information then you'd ask vscode to go to line 16?

@JackCA
Copy link

JackCA commented Dec 23, 2020

there was a response here from a maintainer of vscode suggesting a solution to this.

Wouldn't a good solution to this be a vscode api where cursorDown just has a new boolean argument that is something like openFolds: false. It seems like they are open to that

@halikular
Copy link

halikular commented Jan 18, 2021

@JackCA Annoying that we can't see status on: microsoft/vscode#108960 and no progress here: microsoft/vscode#81498

@dagolinuxoid
Copy link

It looks like the only solution at the moment is to use safe line number to go + G e.g (42G) in order to prevent unfolding.

@strootman
Copy link

It looks like the only solution at the moment is to use safe line number to go + G e.g (42G) in order to prevent unfolding.

If you use relative line numbers, you can supplement this tactic with number+motion.
"Go 42 lines down" ==> 42j

@joehillen
Copy link

IDK, why VSCode team helping us out on this problem. There are more than 6M+ VIM users & I'm one of them cry, We love this extension but So helpless, hopeless.

PRs welcome

@gmarsano-ngp
Copy link

What's the problem?
Just map VSCode fold commands and use gj or gk to move over folded code without open it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests