diff options
Diffstat (limited to 'editors/code/src/util.ts')
-rw-r--r-- | editors/code/src/util.ts | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index 127a9e911..352ef9162 100644 --- a/editors/code/src/util.ts +++ b/editors/code/src/util.ts | |||
@@ -74,10 +74,11 @@ export type RustDocument = vscode.TextDocument & { languageId: "rust" }; | |||
74 | export type RustEditor = vscode.TextEditor & { document: RustDocument }; | 74 | export type RustEditor = vscode.TextEditor & { document: RustDocument }; |
75 | 75 | ||
76 | export function isRustDocument(document: vscode.TextDocument): document is RustDocument { | 76 | export function isRustDocument(document: vscode.TextDocument): document is RustDocument { |
77 | return document.languageId === 'rust' | 77 | // Prevent corrupted text (particularly via inlay hints) in diff views |
78 | // SCM diff views have the same URI as the on-disk document but not the same content | 78 | // by allowing only `file` schemes |
79 | && document.uri.scheme !== 'git' | 79 | // unfortunately extensions that use diff views not always set this |
80 | && document.uri.scheme !== 'svn'; | 80 | // to something different than 'file' (see ongoing bug: #4608) |
81 | return document.languageId === 'rust' && document.uri.scheme === 'file'; | ||
81 | } | 82 | } |
82 | 83 | ||
83 | export function isRustEditor(editor: vscode.TextEditor): editor is RustEditor { | 84 | export function isRustEditor(editor: vscode.TextEditor): editor is RustEditor { |
@@ -93,3 +94,8 @@ export function isValidExecutable(path: string): boolean { | |||
93 | 94 | ||
94 | return res.status === 0; | 95 | return res.status === 0; |
95 | } | 96 | } |
97 | |||
98 | /** Sets ['when'](https://code.visualstudio.com/docs/getstarted/keybindings#_when-clause-contexts) clause contexts */ | ||
99 | export function setContextValue(key: string, value: any): Thenable<void> { | ||
100 | return vscode.commands.executeCommand('setContext', key, value); | ||
101 | } | ||