-
Notifications
You must be signed in to change notification settings - Fork 70
feat: add change selections command #1734
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
base: main
Are you sure you want to change the base?
Conversation
editors/vscode/src/extension.ts
Outdated
}), | ||
); | ||
context.subscriptions.push( | ||
vscode.workspace.onDidOpenTextDocument((doc: vscode.TextDocument) => { | ||
if (doc.isUntitled && window.activeTextEditor?.document === doc) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the doc.isUntitled is a mistake, you probably meant !doc.isUntitled, because, just before on line 166 you return if the document is untitled which makes sense because you don't want to consider it.
if (doc.isUntitled && window.activeTextEditor?.document === doc) { | |
if (!doc.isUntitled && window.activeTextEditor?.document === doc) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, I added comments to the code. I checked it and think of I'm not doing a bad refactor. Please check the comments:
tinymist/editors/vscode/src/extension.ts
Lines 208 to 211 in f4614ee
// Watches the active editor that owning a titled `document` (`!isUntitled`). | |
// | |
// todo: plaintext detection | |
window.onDidChangeActiveTextEditor((editor: TextEditor | undefined) => { |
tinymist/editors/vscode/src/extension.ts
Lines 216 to 223 in f4614ee
// Watches the active editor that owning an untitled `document` (`isUntitled`). | |
// `onDidChangeActiveTextEditor` doesn't capture changes of untitled `document`s. This is because when the user | |
// change language id from `plaintext` to `typst` manually, the editor is not changed but only replacen with a new | |
// document with language id `typst`, in which case vscode doesn't trigger `onDidChangeActiveTextEditor`. | |
// | |
// FIXME1: we could do better by finding a way to handle the focus of `document` with only one handler. | |
// FIXME2: seems like we are also failing to capture changes of language id of titled `document`? | |
vscode.workspace.onDidOpenTextDocument((doc: vscode.TextDocument) => { |
Adding a command to track user selections in the editor, then we can use the
focusing_selection
stored in the global state:tinymist/crates/tinymist/src/server.rs
Lines 79 to 91 in 8db172c
This is unfriendly for the editors that cannot make client-side extensions.