Skip to content

Conversation

Woodii1998
Copy link

@Woodii1998 Woodii1998 commented Aug 9, 2025

What this PR does / why we need it:
I personally prefer using the vert resize and resize commands for adjusting window size. Since I noticed these commands aren’t currently supported, I went ahead and implemented them

Which issue(s) this PR fixes
#9725
This may also partially address
#9227

Special notes for your reviewer:
I’ve only implemented the commonly used parts of these two commands.
For the :resize command, I couldn’t find any built-in VS Code function that achieves an effect similar to workbench.action.toggleEditorWidths in the vertical direction, nor one that sets the editor height to a specific number of lines (e.g., :resize 20).
It’s possible my understanding of VS Code is incomplete, so if you know of a similar command, please let me know and I’ll be happy to update this PR accordingly.

@AzimovParviz
Copy link
Contributor

6 failing
  1) Vertical command
       vertical without command shows argument required error:

      AssertionError [ERR_ASSERTION]: Expected "actual" to be reference-equal to "expected":
+ actual - expected

+ [AssertionError: Should have thrown an error] {
+   actual: undefined,
+   code: 'ERR_ASSERTION',
+   expected: undefined,
+   generatedMessage: false,
+   operator: 'fail'
- [VimError: Argument required] {
-   code: 471
  }

      + expected - actual

       {
      -  "actual": [undefined]
      -  "code": "ERR_ASSERTION"
      -  "expected": [undefined]
      -  "generatedMessage": false
      -  "operator": "fail"
      +  "code": 471
      +  "message": "Argument required"
       }

  	at Context.<anonymous> (out/test/cmd_line/vertical.test.js:56:29)

  2) Vertical command
       vertical with whitespace only shows argument required error:

      AssertionError [ERR_ASSERTION]: Expected "actual" to be reference-equal to "expected":
+ actual - expected

+ [AssertionError: Should have thrown an error] {
+   actual: undefined,
+   code: 'ERR_ASSERTION',
+   expected: undefined,
+   generatedMessage: false,
+   operator: 'fail'
- [VimError: Argument required] {
-   code: 471
  }

      + expected - actual

       {
      -  "actual": [undefined]
      -  "code": "ERR_ASSERTION"
      -  "expected": [undefined]
      -  "generatedMessage": false
      -  "operator": "fail"
      +  "code": 471
      +  "message": "Argument required"
       }

  	at Context.<anonymous> (out/test/cmd_line/vertical.test.js:65:29)

  3) Vertical command
       vertical with unsupported command shows error:

      AssertionError [ERR_ASSERTION]: Expected "actual" to be reference-equal to "expected":
+ actual - expected

+ [AssertionError: Should have thrown an error] {
+   actual: undefined,
+   code: 'ERR_ASSERTION',
+   expected: undefined,
+   generatedMessage: false,
+   operator: 'fail'
- [VimError: Not an editor command: vertical help] {
-   code: 492
  }

      + expected - actual

       {
      -  "actual": [undefined]
      -  "code": "ERR_ASSERTION"
      -  "expected": [undefined]
      -  "generatedMessage": false
      -  "operator": "fail"
      +  "code": 492
      +  "message": "Not an editor command: vertical help"
       }

  	at Context.<anonymous> (out/test/cmd_line/vertical.test.js:74:29)

  4) Vertical command
       vertical resize with invalid argument shows error:

      AssertionError [ERR_ASSERTION]: Expected "actual" to be reference-equal to "expected":
+ actual - expected

+ [AssertionError: Should have thrown an error for invalid argument] {
+   actual: undefined,
+   code: 'ERR_ASSERTION',
+   expected: undefined,
+   generatedMessage: false,
+   operator: 'fail'
- [VimError: Invalid argument: abc] {
-   code: 474
  }

      + expected - actual

       {
      -  "actual": [undefined]
      -  "code": "ERR_ASSERTION"
      -  "expected": [undefined]
      -  "generatedMessage": false
      -  "operator": "fail"
      +  "code": 474
      +  "message": "Invalid argument: abc"
       }

  	at Context.<anonymous> (out/test/cmd_line/vertical.test.js:222:29)

  5) Vertical command
       vertical resize with invalid format shows error:

      AssertionError [ERR_ASSERTION]: Expected "actual" to be reference-equal to "expected":
+ actual - expected

+ [AssertionError: Should have thrown an error for invalid format] {
+   actual: undefined,
+   code: 'ERR_ASSERTION',
+   expected: undefined,
+   generatedMessage: false,
+   operator: 'fail'
- [VimError: Invalid argument: +abc] {
-   code: 474
  }

      + expected - actual

       {
      -  "actual": [undefined]
      -  "code": "ERR_ASSERTION"
      -  "expected": [undefined]
      -  "generatedMessage": false
      -  "operator": "fail"
      +  "code": 474
      +  "message": "Invalid argument: +abc"
       }

  	at Context.<anonymous> (out/test/cmd_line/vertical.test.js:231:29)

  6) Vertical command
       vertical resize with mixed format shows error:

      AssertionError [ERR_ASSERTION]: Expected "actual" to be reference-equal to "expected":
+ actual - expected

+ [AssertionError: Should have thrown an error for mixed format] {
+   actual: undefined,
+   code: 'ERR_ASSERTION',
+   expected: undefined,
+   generatedMessage: false,
+   operator: 'fail'
- [VimError: Invalid argument: 5+] {
-   code: 474
  }

      + expected - actual

       {
      -  "actual": [undefined]
      -  "code": "ERR_ASSERTION"
      -  "expected": [undefined]
      -  "generatedMessage": false
      -  "operator": "fail"
      +  "code": 474
      +  "message": "Invalid argument: 5+"
       }

  	at Context.<anonymous> (out/test/cmd_line/vertical.test.js:240:29)

Error: 6 tests failed.

Just cloned your fork and checkout to the branch to run the tests. Is this just WIP or do you get different errors?
This is when running npx gulp test

@Woodii1998
Copy link
Author

6 failing
  1) Vertical command
       vertical without command shows argument required error:

      AssertionError [ERR_ASSERTION]: Expected "actual" to be reference-equal to "expected":
+ actual - expected

+ [AssertionError: Should have thrown an error] {
+   actual: undefined,
+   code: 'ERR_ASSERTION',
+   expected: undefined,
+   generatedMessage: false,
+   operator: 'fail'
- [VimError: Argument required] {
-   code: 471
  }

      + expected - actual

       {
      -  "actual": [undefined]
      -  "code": "ERR_ASSERTION"
      -  "expected": [undefined]
      -  "generatedMessage": false
      -  "operator": "fail"
      +  "code": 471
      +  "message": "Argument required"
       }

  	at Context.<anonymous> (out/test/cmd_line/vertical.test.js:56:29)

  2) Vertical command
       vertical with whitespace only shows argument required error:

      AssertionError [ERR_ASSERTION]: Expected "actual" to be reference-equal to "expected":
+ actual - expected

+ [AssertionError: Should have thrown an error] {
+   actual: undefined,
+   code: 'ERR_ASSERTION',
+   expected: undefined,
+   generatedMessage: false,
+   operator: 'fail'
- [VimError: Argument required] {
-   code: 471
  }

      + expected - actual

       {
      -  "actual": [undefined]
      -  "code": "ERR_ASSERTION"
      -  "expected": [undefined]
      -  "generatedMessage": false
      -  "operator": "fail"
      +  "code": 471
      +  "message": "Argument required"
       }

  	at Context.<anonymous> (out/test/cmd_line/vertical.test.js:65:29)

  3) Vertical command
       vertical with unsupported command shows error:

      AssertionError [ERR_ASSERTION]: Expected "actual" to be reference-equal to "expected":
+ actual - expected

+ [AssertionError: Should have thrown an error] {
+   actual: undefined,
+   code: 'ERR_ASSERTION',
+   expected: undefined,
+   generatedMessage: false,
+   operator: 'fail'
- [VimError: Not an editor command: vertical help] {
-   code: 492
  }

      + expected - actual

       {
      -  "actual": [undefined]
      -  "code": "ERR_ASSERTION"
      -  "expected": [undefined]
      -  "generatedMessage": false
      -  "operator": "fail"
      +  "code": 492
      +  "message": "Not an editor command: vertical help"
       }

  	at Context.<anonymous> (out/test/cmd_line/vertical.test.js:74:29)

  4) Vertical command
       vertical resize with invalid argument shows error:

      AssertionError [ERR_ASSERTION]: Expected "actual" to be reference-equal to "expected":
+ actual - expected

+ [AssertionError: Should have thrown an error for invalid argument] {
+   actual: undefined,
+   code: 'ERR_ASSERTION',
+   expected: undefined,
+   generatedMessage: false,
+   operator: 'fail'
- [VimError: Invalid argument: abc] {
-   code: 474
  }

      + expected - actual

       {
      -  "actual": [undefined]
      -  "code": "ERR_ASSERTION"
      -  "expected": [undefined]
      -  "generatedMessage": false
      -  "operator": "fail"
      +  "code": 474
      +  "message": "Invalid argument: abc"
       }

  	at Context.<anonymous> (out/test/cmd_line/vertical.test.js:222:29)

  5) Vertical command
       vertical resize with invalid format shows error:

      AssertionError [ERR_ASSERTION]: Expected "actual" to be reference-equal to "expected":
+ actual - expected

+ [AssertionError: Should have thrown an error for invalid format] {
+   actual: undefined,
+   code: 'ERR_ASSERTION',
+   expected: undefined,
+   generatedMessage: false,
+   operator: 'fail'
- [VimError: Invalid argument: +abc] {
-   code: 474
  }

      + expected - actual

       {
      -  "actual": [undefined]
      -  "code": "ERR_ASSERTION"
      -  "expected": [undefined]
      -  "generatedMessage": false
      -  "operator": "fail"
      +  "code": 474
      +  "message": "Invalid argument: +abc"
       }

  	at Context.<anonymous> (out/test/cmd_line/vertical.test.js:231:29)

  6) Vertical command
       vertical resize with mixed format shows error:

      AssertionError [ERR_ASSERTION]: Expected "actual" to be reference-equal to "expected":
+ actual - expected

+ [AssertionError: Should have thrown an error for mixed format] {
+   actual: undefined,
+   code: 'ERR_ASSERTION',
+   expected: undefined,
+   generatedMessage: false,
+   operator: 'fail'
- [VimError: Invalid argument: 5+] {
-   code: 474
  }

      + expected - actual

       {
      -  "actual": [undefined]
      -  "code": "ERR_ASSERTION"
      -  "expected": [undefined]
      -  "generatedMessage": false
      -  "operator": "fail"
      +  "code": 474
      +  "message": "Invalid argument: 5+"
       }

  	at Context.<anonymous> (out/test/cmd_line/vertical.test.js:240:29)

Error: 6 tests failed.

Just cloned your fork and checkout to the branch to run the tests. Is this just WIP or do you get different errors? This is when running npx gulp test

Sorry, I might not have noticed it at the time. Let me quickly fix this issue

…tatus messages for invalid commands and arguments
@Woodii1998
Copy link
Author

done

@AzimovParviz
Copy link
Contributor

The tests are passing now, thanks. I tried the command a bit and it feels smooth and how I imagine it should work in vim (never really used the vertical command in vim personally, always relied on ctrl+w). I am not a maintainer sadly so I can't approve but I like your implementation.

LGTM

Co-authored-by: AzimovParviz <[email protected]>
@AzimovParviz
Copy link
Contributor

I tested it and it actually fails to parse it as a valid command as far as I can tell at a glance

@J-Fields apologies for pinging, would a command like 'vertical-resize' with a dash in it be supported by the current exCommandParser? I tried playing around with the grep command and with different variations like ['vim-grep', ''] or ['vim-', 'grep'] it always treats -grep as the first argument:
Pasted Graphic

Same with the vertical-resize command. Should something be done about exCommandParser or should each command implementation deal with that by itself?

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