Change:
<!-- Do Not Delete This! bugreporttemplate --<!-- Please read our Rules of Conduct: --<!-- Read our guide about submitting issues: --<!-- Search existing issues to avoid creating duplicates. --<!-- Test using the latest Insiders build to see if your issue has already been fixed: --<!-- Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. --<!-- Launch with to check. --Does this issue occur when all extensions are disabled?: Yes <!-- If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. --<!-- Issues caused by an extension need to be reported directly to the extension publisher. The 'Help Report Issue' dialog can assist with this. --- VS Code Version: 1.70.0 OS Version: macOS Monterey 12.5 Steps to Reproduce: relative line numbers in user settings () a code file (TypeScript in my case). fold a function (I use , ) the caret on the first line of the resulting fold. at the relative line of the end curly brace for the function. the relative line number is 1. ! This relative line number used to be the actual line count, ignoring the code folding. I read in the release notes that you are doing a lot of work with code folding, and I didn't know if you knew this was changed behavior. I can understand that some may want this new behavior, but there should be a setting for it. Maybe there is, but I can't find it! It probably doesn't matter, but my use case is that I use VsCodeVim and I use the relative line numbers to yank or drop an entire function/class/whatever. But this isn't their problem directly though, and of course I tested this behavior with extensions disabled. Thanks for your help.
This change was deliberate and is separate from the recent work on folding ranges. See I have no comment on which way is preferable, just adding the link here to what caused this.
(Just) like OP im using VSCode NeoVim and rely on relative line numbers to not be ignoring if code is folded or not. I sincerely hope this new behaviour will become optional as I've gotten SO used to this.
+1 I was totally used to the relative numbering with vim extension. Folds should definitely not obscure relative line number of following lines
Thank you very much for the link . I guess the difference between that post and mine is that I used double quotes when I said "wrong". Definitely is breaking behavior and should have been an option. I would say the implementors were unaware of the vim aspect of this, but the OP in that thread actually mentions it. So it's a real head scratcher why the existing (and long-standing) behavior was changed. I strongly hope the team reconsiders this breaking change, since vscodevim has 4M downloads since 2015 - long before the OP claimed without double quotes that the relative line numbers were wrong. And NOT AT ALL to challenge the utility of it, but I'm totally ignorant as to what is the use of relative line numbers skipping folding? Life is so awesomely immense and diverse, I'm sure it's just something I'm unaware of.
I hope this new behavior should get a new option rather than breaking the existing behavior. New behavior breaks a workflow when using vscodevim in yanking and deleting the line.
This was an intentional bugfix done via . We initially support for relative line numbers as this was a highly requested feature from folks coming over from vim, so when I saw (i.e. how vim skips over folded regions when counting relative line numbers), I considered to be a bug. We can easily revert the change and go back to the previous relative line counting, but I'm honestly a bit confused here with regards to what folks really expect . Is this relative line counting tweakable via a setting in vim?
I see why it was considered a bug. Native vim (or at least nvim) does relative numbers the same way as the PR in question introduced. The big difference however is that in nvim when there are folded sections, if you in ig: <img width="578" alt="image" src="https://user-"You would end up in line ( folded lines were skipped) Whereas with VsCode vim, with the new change you would end up opening the fold. That is, it would go down literally 4 lines down from the cursor. Thus, there is no way for the user to actually get to the desired line quickly by using relative line numbers So I guess the discussion would have to be whether the solving of this issue now it is a bug for VsCode vim?
I see! Thank you for clarifying. I will roll us back to the previous behaviour as default and maybe introduce a setting for the new line counting or remove it altogether.
I am not a vim proper user, nor a neovim one. I started using vim in vscode several years ago. I tried vim and neovim, but I prefer vscode. So I don't know about vim. But I would imagine if you want to delete a function that takes up 10 lines and it is folded and shows only 1 line in relative line numbers, then when you hit (delete 1 line down) it would delete the entire folded section and not just a single invisible line. If it doesn't do this, then it also would be poor IMO. When I want to delete entire functions/classes/etc. which can be more than one screen in height, I will fold that section and look at the relative line number and use it in the command. This goes not only for (deleting), but also for (yanking/copying) and (commenting). Probably other commands as well. This is integral and used many many many times per code session. There are other vim specific tricks for blocks and other things which I also use, but I use folding - often in combination with folding entire files to "skim" at a higher level. So it's already folded often and I just look at the relative line number and do it. All of that said, I love all of the work y'all do on vscode making it the best out there (IMO). I could see if you're getting other vim proper people who are complaining that you would see it as one-sided and not requiring a setting flag. But I didn't know that they were calling for the change, and I would say instead of reverting it, you would add the setting flag and set it to whoever you think the majority is. Maybe you can ask the others who were asking for it the behavior of vim proper, if it deletes the entire fold when doing the commands. Because it doesn't in vscode, rather only the invisible lines. I'd be dumbfounded if that's really expected behavior in vim proper.
I just want to chime in that, to me, the original don't skip over folded content when counting relative line numbers is what I would expect. Thank you for considering reverting the changes.
Thank you !!

Discussion:
private _lineNumbersLeft!: number; private _lineNumbersWidth!: number; private _lastCursorModelPosition: Position; <del> private _lastCursorViewPosition: Position; </del> private _renderResult: string[] | null; private _activeLineNumber: number;

this._readConfig(); this._lastCursorModelPosition = new Position(1, 1); <del> this._lastCursorViewPosition = new Position(1, 1); </del> this._renderResult = null; this._activeLineNumber = 1; this._context.addEventHandler(this);

} public override onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean { const primaryViewPosition = e.selections[0].getPosition(); <del> this._lastCursorViewPosition = primaryViewPosition; </del> this._lastCursorModelPosition = this._context.viewModel.coordinatesConverter.convertViewPositionToModelPosition(primaryViewPosition); let shouldRender = false;

return this._renderCustomLineNumbers(modelLineNumber); } <ins> if (this._renderLineNumbers === RenderLineNumbersType.Relative) { const diff = Math.abs(this._lastCursorModelPosition.lineNumber - modelLineNumber); if (diff === 0) { return '<span class="relative-current-line-number">' + modelLineNumber + '</span>'; } return String(diff); } </ins> if (this._renderLineNumbers === RenderLineNumbersType.Interval) { if (this._lastCursorModelPosition.lineNumber === modelLineNumber) { return String(modelLineNumber);

const visibleEndLineNumber = ctx.visibleRange.endLineNumber; const common = '<div class="' + LineNumbersOverlay.CLASS_NAME + lineHeightClassName + '" style="left:' + this._lineNumbersLeft + 'px;width:' + this._lineNumbersWidth + 'px;">'; <del> let relativeLineNumbers: number[] | null = null; if (this._renderLineNumbers === RenderLineNumbersType.Relative) { relativeLineNumbers = new Array(visibleEndLineNumber - visibleStartLineNumber + 1); if (this._lastCursorViewPosition.lineNumber >= visibleStartLineNumber && this._lastCursorViewPosition.lineNumber <= visibleEndLineNumber) { relativeLineNumbers[this._lastCursorViewPosition.lineNumber - visibleStartLineNumber] = this._lastCursorModelPosition.lineNumber; } // Iterate up to compute relative line numbers { let value = 0; for (let lineNumber = this._lastCursorViewPosition.lineNumber + 1; lineNumber <= visibleEndLineNumber; lineNumber++) { const modelPosition = this._context.viewModel.coordinatesConverter.convertViewPositionToModelPosition(new Position(lineNumber, 1)); const isWrappedLine = (modelPosition.column !== 1); if (!isWrappedLine) { value++; } if (lineNumber >= visibleStartLineNumber) { relativeLineNumbers[lineNumber - visibleStartLineNumber] = isWrappedLine ? 0 : value; } } } // Iterate down to compute relative line numbers { let value = 0; for (let lineNumber = this._lastCursorViewPosition.lineNumber - 1; lineNumber >= visibleStartLineNumber; lineNumber--) { const modelPosition = this._context.viewModel.coordinatesConverter.convertViewPositionToModelPosition(new Position(lineNumber, 1)); const isWrappedLine = (modelPosition.column !== 1); if (!isWrappedLine) { value++; } if (lineNumber <= visibleEndLineNumber) { relativeLineNumbers[lineNumber - visibleStartLineNumber] = isWrappedLine ? 0 : value; } } } } </del> const lineCount = this._context.viewModel.getLineCount(); const output: string[] = []; for (let lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {

} } <del> let renderLineNumber: string; if (relativeLineNumbers) { const relativeLineNumber = relativeLineNumbers[lineIndex]; if (this._lastCursorViewPosition.lineNumber === lineNumber) { // current line! renderLineNumber = `<span class="relative-current-line-number">${relativeLineNumber}</span>`; } else if (relativeLineNumber) { renderLineNumber = String(relativeLineNumber); } else { renderLineNumber = ''; } } else { renderLineNumber = this._getLineRenderLineNumber(lineNumber); } </del> <ins> const renderLineNumber = this._getLineRenderLineNumber(lineNumber); </ins> if (renderLineNumber) { if (lineNumber === this._activeLineNumber) {