You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vim has handy commands for scrolling without moving the cursor, e.g. zt, which scrolls the screen so that the line with the current cursor is placed as the first line. E.g., I often do actions like /main(zt, so that I can see as much of the main function as possible.
Would it be possible to implement zt, zb and zz?
Thanks!
Scroll window upwards/downwards by lines (real line) or window size (eg, half window size)
Scroll horizontal scrollbar by column numbers.
Horizontal scrolling is already implemented by cursor move commands. Hence marking this done. See VIM API Gaps #8997
About the first task, just realized that we have scrollLineUpscrollLineDown, scrollPageUp and scrollPageDown commands already. The only part missing is scrolling half page down.
Users are allowed to scroll line up or down with numeric prefix, like 10 Ctrl-E to scroll ten lines down. If we repeat scrollLineUp ten times, I'm worried we might have performance hit somehow. So a generic command takes line number as argument will be better IMHO.
error.stack
Error: argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true
at f (file:///C:/Program Files (x86)/Microsoft VS Code Insiders/resources/app/out/vs/workbench/workbench.main.js:29:13605)
Peng Lyu (@rebornix) Hmm strange, I do not see any issue while using this command in our sample Vim extension. Can you show me how are you calling this command?
Sandeep Somavarapu (@sandy081) I just simply called await vscode.commands.executeCommand('editorScroll', {to: 'up', by: 'line', value: '1'});. This error occurs always on 1.5.0-Insider.
Finally I saw the problem. I'm not using the value of to correctly, I thought to: 'up' will move current line move upwards but actually it will move the line downwards. It behaves the same as Vim.
The only problem left is scrolling down the window await vscode.commands.executeCommand('editorScroll', {to: 'down', by: 'line', value: '1'}); doesn't work on the first line in the screen.
I guess you disable scrolling downwards the window on the first line as this command is not cursor moving and if we allow this command on the first line, the cursor will be out of current viewport, right? However Vim's behavior on this is scrolling lines/pages without moving cursor, if the final viewport doesn't contain the original line, Vim will put the cursor on the beginning of the nearest visible line in viewport.
Peng Lyu (@rebornix) editorScroll command does not disable any scrolling in the above scenario. It just scrolls the window up or down irrespective of the cursor position. It does not reposition the cursor if it goes outside view port. I think this is beyond the scope of command's functionality.
Sandeep Somavarapu (@sandy081) that's what I'm seeing, now I reposition the cursor in VSCodeVim's code and it works well. The only issue I see is scrolling doesn't work on first line, can you help confirm?
Sandeep Somavarapu (@sandy081) Played with revealLine not sure I'm doing correctly but when I run await vscode.commands.executeCommand('revealLine', {lineNumber: 1, at: 'top'});, the window scroll down by 1 line and the cursor doesn't move. The cursor behavior is expected but seems top is not working. I suppose 'revealLine', {lineNumber: 1, at: 'top'} will move current line to the top first line in the window, right?
BTW, I'm checking the result of this command by setting breakpoint before and after this line, so there should be other side effect by VSCodeVim.
Activity
rebornix commentedon Jul 28, 2016
About the first task, just realized that we have
scrollLineUpscrollLineDown,scrollPageUpandscrollPageDowncommands already. The only part missing is scrolling half page down.Users are allowed to scroll line up or down with numeric prefix, like 10 Ctrl-E to scroll ten lines down. If we repeat
scrollLineUpten times, I'm worried we might have performance hit somehow. So a generic command takes line number as argument will be better IMHO.Implement editor scroll command - #9609
Editor scroll by wrapped lines, lines, page, half page #9609
sandy081 commentedon Aug 4, 2016
Peng Lyu (@rebornix) Delivered a new command called
editorScroll. Try it and let me know the feedback. See the description for usage.Thanks
rebornix commentedon Aug 8, 2016
Sandeep Somavarapu (@sandy081) I just ran your commands but see below errors
any idea?
sandy081 commentedon Aug 15, 2016
Peng Lyu (@rebornix) Hmm strange, I do not see any issue while using this command in our sample Vim extension. Can you show me how are you calling this command?
rebornix commentedon Aug 16, 2016
Sandeep Somavarapu (@sandy081) I just simply called
await vscode.commands.executeCommand('editorScroll', {to: 'up', by: 'line', value: '1'});. This error occurs always on 1.5.0-Insider.rebornix commentedon Aug 16, 2016
Finally I saw the problem. I'm not using the value of
tocorrectly, I thoughtto: 'up'will move current line move upwards but actually it will move the line downwards. It behaves the same as Vim.The only problem left is scrolling down the window
await vscode.commands.executeCommand('editorScroll', {to: 'down', by: 'line', value: '1'});doesn't work on the first line in the screen.I guess you disable scrolling downwards the window on the first line as this command is not cursor moving and if we allow this command on the first line, the cursor will be out of current viewport, right? However Vim's behavior on this is scrolling lines/pages without moving cursor, if the final viewport doesn't contain the original line, Vim will put the cursor on the beginning of the nearest visible line in viewport.
sandy081 commentedon Aug 16, 2016
Peng Lyu (@rebornix) editorScroll command does not disable any scrolling in the above scenario. It just scrolls the window up or down irrespective of the cursor position. It does not reposition the cursor if it goes outside view port. I think this is beyond the scope of command's functionality.
rebornix commentedon Aug 16, 2016
Sandeep Somavarapu (@sandy081) that's what I'm seeing, now I reposition the cursor in VSCodeVim's code and it works well. The only issue I see is scrolling doesn't work on first line, can you help confirm?
#9609 - Implement reveal line command
#9609 Reveal cursor while scrolling
sandy081 commentedon Aug 19, 2016
Peng Lyu (@rebornix) Enhanced
editorScrollcommand to reveal cursor while scrolling. See the description for syntax and how to use.Also implemented
revealLinecommand to reveal the line at the given logical position in the screen. Again see the description for usage.rebornix commentedon Aug 23, 2016
Sandeep Somavarapu (@sandy081) Played with
revealLinenot sure I'm doing correctly but when I runawait vscode.commands.executeCommand('revealLine', {lineNumber: 1, at: 'top'});, the window scroll down by 1 line and the cursor doesn't move. The cursor behavior is expected but seemstopis not working. I suppose'revealLine', {lineNumber: 1, at: 'top'}will move current line to the top first line in the window, right?BTW, I'm checking the result of this command by setting breakpoint before and after this line, so there should be other side effect by VSCodeVim.
sandy081 commentedon Aug 23, 2016
Peng Lyu (@rebornix) Yeah, please check if there is some side effect from Vim extension, because this was working properly in the sample.
nschurmann commentedon Jan 4, 2017
Great, where do i write this config?
rebornix commentedon Jan 13, 2017
nschurmann #14854 (comment)