menu
書いてる野郎
orebike@gmail.com
ver 1.67
で発生している。
どういう経緯かわからないが、この切り替え部分のソースコード Windows 版だとこのあたりにある → Default\Extensions\dbepggeogbaibhgnhhndojpepiihcmeb\1.67_0\content_scripts\mode_visula.js
こいつが、このように記述されている。これは 390行目付近
"v"() { return new VisualMode; }, "V"() { return new VisualLineMode; }, "c"() { // If we're already in caret mode, or if the selection looks the same as it would in caret mode, then // callapse to anchor (so that the caret-mode selection will seem unchanged). Otherwise, we're in visual // mode and the user has moved the focus, so collapse to that. if ((this.name === "caret") || (this.selection.toString().length <= 1)) this.movement.collapseSelectionToAnchor(); else this.movement.collapseSelectionToFocus(); return new CaretMode; },
おかしい所は この return
の後の new
の所で、コンストラクタ呼び出しがされていない。
単にクラス名を指定しているだけ、JavaScript 的にこういう記述が許されるのか知らんがなんか変である。TypeScript
ではこのような記述が許されているのでそれと被っている?
それと合わせて、他の部分を参考に書き直すとこうなる。
"v"() { const mode = new VisualMode(); mode.init(); return mode; }, "V"() { const mode = new VisualLineMode(); mode.init(); return mode; }, "c"() { // If we're already in caret mode, or if the selection looks the same as it would in caret mode, then // callapse to anchor (so that the caret-mode selection will seem unchanged). Otherwise, we're in visual // mode and the user has moved the focus, so collapse to that. if ((this.name === "caret") || (this.selection.toString().length <= 1)) this.movement.collapseSelectionToAnchor(); else this.movement.collapseSelectionToFocus(); const mode = new CaretMode(); mode.init(); return mode; },
これでとりあえず直ったのでよしとする。