aioutecism/amVim-for-VSCode

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

Opened this issue · 9 comments

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).

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.

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.

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.

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.

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. 😅

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.

tslint.json 😖

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!

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. 😄