Skip to content

Screen lines and characters. - #486

Merged
johnfn merged 4 commits into
VSCodeVim:masterfrom
rebornix:ScreenLine
Jul 29, 2016
Merged

johnfn merged 4 commits into
VSCodeVim:masterfrom
rebornix:ScreenLine

Conversation

@rebornix

@rebornix rebornix commented Jul 20, 2016 •

Copy link
Copy Markdown
Member

Yay! We love PRs! 🎊

Please include a description of your change & check your PR against this list, thanks:

  • Commit message has a short title & issue references
  • Commits are squashed
  • It builds and tests pass (e.g gulp tslint)

We are adding APIs for screen lines/characters in Insider and this PR is integrating those APIs for following commands

  • g0
  • g^
  • 🔢 g$
  • gm
  • 🔢 gk
  • 🔢 gj
  • 🔢 H
  • M
  • 🔢 L

As @johnfn mentioned while I did #478, the way we implment Movement in VSCodeVim is calculating the target Position or Selection and update the View in a central place (modelHandler). We are likely doing this from the very beginning.

While we are exposing commands in VS Code, we try to avoid exposing View Model information as they are way too complex and always require additional work. Take scroll to next screen line as example, we want VSCodeVim just provides the Position information and handle the movment ourselves, but for other extension authors or just users who want to customize key bindings, they have to leverage other APIs to move the cursor to target position.

So in this PR, I'm calling VS Code API to do the real movment or selection and return the correct Position/Movement information after the command is executed.

@rebornix rebornix changed the title [WIP] Screen lines and characters. Screen lines and characters. Jul 25, 2016
@rebornix

Copy link
Copy Markdown
Member Author

As we already hold on new features on Code for July release, I postpone zh, zH, etc commands to later weeks and it's tracked by #511. So I removed WIP prefix and it's ready for review @johnfn @jpoon .

Comment thread src/actions/actions.ts

if (vimState.currentMode === ModeName.Normal) {
return Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.active);
} else {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a big bummer; it will slow down macros and . considerably.

I know that it's not your fault at all, but any additional griping you can do in the direction of VSCode would be helpful 😄

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it's a bummer when users use this command quite often. Do we have any benchmark (or you have ideas about how) about commands to help measure how bad it is?

If it turns out to be unacceptablely slow, I'd like to push it hard from Code side.

@johnfn johnfn Jul 26, 2016 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.

Upon reflection, a mild slowdown here is acceptable, because not too many people use these commands (they are a bit esoteric). At this point, I think that a history API is priority number 1, and that we can safely bump the priority of getting actual positions down. I just hope that the people over at MS don't mark this as finished and forget about it.

If you can push just for one thing, I would really like the history API. We are really suffering a lot because of our reimplementation of that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me make History the 1st feature request for next sprint.

@johnfn

johnfn commented Jul 26, 2016

Copy link
Copy Markdown
Member

When you fix up my minor comments this LGTM.

I would like to hold off until vscode 1.4 ships with the new features before merging this however, as I suspect a lot of our users are not using the insiders version, and we want to support them as well.

@rebornix

Copy link
Copy Markdown
Member Author

@johnfn fixed per your comments.

Actually you don't need to wait for 1.4 as these commands have no side effect in any version below, that's saying even if you are using an old Code, when you run these new Code commands, Code will just eat them and emit nothing.

This is also a good way to test our new features unlocked by Code. People who use Insider can try these new features first and may report issues if there is any bug. The key point is, making sure newly added features have no side effect and are backwards compatible.

@johnfn
johnfn merged commit 8150c0b into VSCodeVim:master Jul 29, 2016
@johnfn

johnfn commented Jul 29, 2016

Copy link
Copy Markdown
Member

Thanks @rebornix!

@jpoon jpoon mentioned this pull request Sep 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants