ttrace / vscode-language-japanese-novel

Visual Studio Code で小説を執筆する時に使う言語拡張です。
MIT License
391 stars 27 forks source link

remove non-null assertion; do nothing when `activeTextEditor` is null #11

Closed takahashim closed 3 years ago

takahashim commented 3 years ago

起動直後に「縦書きプレビュー」や「プレビューサーバー起動」を実行しようとすると、たまにエラーになることがありました。

あれこれ試してみたところ、テキストにカーソルがない状態で実行しようとすると vscode.window.activeTextEditor がnullになり、[error] TypeError: Cannot read property 'document' of undefined というエラーが発生するようでした。

これはactiveTextEditorの存在チェックを入れて、nullのときは無視して何もしないようにすると治るようです。

ttrace commented 3 years ago

ありがとうございます。マージします。

ttrace commented 3 years ago

originEditor変数を使って制御しようとしていたのですが、こちらの方が良いですね。 採用します。