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

Some commands are (sometimes) broken in VS Code 1.75.0+ #317

Open
mtsknn opened this issue Mar 11, 2023 · 9 comments
Open

Some commands are (sometimes) broken in VS Code 1.75.0+ #317

mtsknn opened this issue Mar 11, 2023 · 9 comments

Comments

@mtsknn
Copy link
Contributor

mtsknn commented Mar 11, 2023

All commands mentioned below misbehave only sometimes, not always! Seems random.

I haven't investigated the cause of the bug(s) yet, but I might do it some day soon because these misbehaviors are annoying. (If someone else is willing to investigate this before me, go for it!)

I don't know what VS Code version broke these commands, but they are broken at least in 1.76.1.

Visual c and normal ciw

This has happened to me many times in Markdown files ([] = cursor in normal mode; | = cursor in insert mode):

  • - fo[o]viwc → should be - | but is sometimes -| (the cursor is one character too left)
  • - fo[o]vbc → same as above
  • - fo[o]ciw → same as above
  • - f[o]ociw → same as above
  • + possibly other scenarios

I don't believe that the problem is related to Markdown; I have just noticed this often in Markdown files.

Normal o

I have noticed this many times when adding new nested list items in Markdown files:

  • - fo[o]o → should be | but is sometimes  | 

So again the cursor is one character too left.

Visual J

Same here: the cursor is one character too left after joining lines with J.

test/ModeVisual/J.test.ts sometimes fails when changing the VS Code version from 1.62.0 to 1.76.1 in test/runTest.ts, so this could be straightforward to investigate. Fixing this might also fix the other two commands (which apparently are missing test cases).

@mtsknn
Copy link
Contributor Author

mtsknn commented Mar 12, 2023

I have been trying to investigate why J.test.ts randomly fails but haven't had success yet.

But I did find out that the J tests started to randomly fail with VS Code 1.75.0.

I first modified J.test.ts to run the tests dozens of times (quick and dirty 😄):

// Before
for (let i = 0; i < testCases.length; i++) {
  BlackBox.run(testCases[i]);
}

// After
for (let i = 0; i < testCases.length * 50; i++) {
  BlackBox.run(testCases[i % testCases.length]);
}

Then I ran the tests with VS Code versions 1.63.0–1.74.0 (changed the version to test/runTest.ts and ran npm t) and all tests passed with every version. With version 1.75.0 the tests started to randomly break.

Some test failures output this error:

rejected promise not handled within 1 second: Error: Illegal value for `line`
stack trace: Error: Illegal value for `line`
	at v.t (/Users/mts/Documents/repos/amvim/.vscode-test/vscode-darwin-arm64-1.75.0/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:95:966)
	at Object.lineAt (/Users/mts/Documents/repos/amvim/.vscode-test/vscode-darwin-arm64-1.75.0/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:95:90)
	at /Users/mts/Documents/repos/amvim/dist/extension.js:1995:43
	at Array.map (<anonymous>)
	at ActionSelection.validateSelections (/Users/mts/Documents/repos/amvim/dist/extension.js:1990:65)
	at /Users/mts/Documents/repos/amvim/dist/extension.js:1253:57

Next (not today) I'll check if ActionSelection.validateSelections (mentioned in the stack trace) is somehow related.

@alisonatwork
Copy link
Collaborator

Thanks for this research! I haven't had time yet to look into this, but it's very helpful to have identified the version at which things started to go wrong.

@alisonatwork
Copy link
Collaborator

Alright, I finally had some time to look at this again. The first thing I have done is upgrade to the latest everything and set vscode engine to 1.74.0 so that we can rule out any interfering strangeness in the dependencies. I encountered the same problem you are describing here as soon as I tried to bump the engine version to 1.75.0 - the J tests become "consistently flaky".

I suspect that if we can figure out what is causing this off-by-one cursor problem in the flaky J test then it might also solve the o problem and other off-by-ones.

@alisonatwork
Copy link
Collaborator

Alright, I have a "fix" at least for the test flakiness, and it has been released as on Github as version 1.37.0. Not available on VS Code Marketplace or Open VSX yet due to both of those marketplaces have token problems, hopefully to be resolved soon. If you feel like compiling your own version, please give it a run through and let me know if the problems at least reduce somewhat.

@mtsknn
Copy link
Contributor Author

mtsknn commented Feb 28, 2024

Sounds great, thanks for investigating and (hopefully) fixing this!

I just installed 1.37.0 with these steps (required some googling):

  1. npx @vscode/vsce package to package the extension
  2. code --install-extension amvim-1.37.0.vsix to install the extension

Now let's hope the problems are reduced or even eliminated. 🤞


Side note: step 1 printed two warnings and one gotcha:

  1. WARNING Using '*' activation is usually a bad idea as it impacts performance.
    More info: https://code.visualstudio.com/api/references/activation-events#Start-up

    No idea if this could be improved somehow.

  2. WARNING LICENSE, LICENSE.md, or LICENSE.txt not found

    There's "license": "ISC" in package.json, but indeed there's no LICENSE file in the repo.

  3. This extension consists of 767 files, out of which 282 are JavaScript files. For performance reasons, you should bundle your extension: https://aka.ms/vscode-bundle-extension. You should also exclude unnecessary files by adding them to your .vscodeignore: https://aka.ms/vscode-vscodeignore

    Webpack is already used; I wonder if the bundling could be improved somehow.

Would be nice to work on those points some day™ but no promises. 😅

@alisonatwork
Copy link
Collaborator

Number one unfortunately can't be gotten rid of, although you can use a flag to disable the warning in the build (not helpful if you run it manually). For the license file I will have to talk to the original maintainer :)

On the JavaScript thing, that shouldn't happen 🤔 It's possible that you had an old build hanging around from before that didn't get ignore, or perhaps you didn't do a full npm ci to upgrade to latest webpack? This is all I have on my version waiting to be pushed to the marketplaces...

$ unzip -t amvim-1.37.0.vsix
Archive:  amvim-1.37.0.vsix
    testing: extension.vsixmanifest   OK
    testing: [Content_Types].xml      OK
    testing: extension/dist/extension.js   OK
    testing: extension/images/icon.png   OK
    testing: extension/package.json   OK
    testing: extension/README.md      OK
    testing: extension/tslint.json    OK
No errors detected in compressed data of amvim-1.37.0.vsix.

@alisonatwork
Copy link
Collaborator

tslint.json 😖

@mtsknn
Copy link
Contributor Author

mtsknn commented Feb 28, 2024

perhaps you didn't do a full npm ci to upgrade to latest webpack?

Whoops, true! Running npm ci first silenced the message. 👍 Thanks again!

@mtsknn
Copy link
Contributor Author

mtsknn commented Apr 26, 2024

All right, I have bee running v1.37.0 for two months now, and the issue is almost gone. The cursor position is still broken occasionally, maybe a few times a week; I don't know better as I haven't kept a log.

So thanks for the fix once again! This is good enough for me now; the problem is so rare that it doesn't annoy me anymore. 😄

@mtsknn mtsknn changed the title Some commands are (sometimes) broken in VS Code 1.76.1 Some commands are (sometimes) broken in VS Code 1.75.0+ Apr 26, 2024
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

2 participants