aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/util.ts
diff options
context:
space:
mode:
authorVeetaha <[email protected]>2020-03-07 12:07:44 +0000
committerVeetaha <[email protected]>2020-03-07 12:08:35 +0000
commita63446f2549afbeafe632c425112b7c38b5c9991 (patch)
treede59f376c1101a122b8abdcf0e1f7a9a53c45e23 /editors/code/src/util.ts
parent3d93e2108e182350e8bbf51d02a76c85ef831f8e (diff)
vscode: prerefactor util.ts and ctx.ts
Diffstat (limited to 'editors/code/src/util.ts')
-rw-r--r--editors/code/src/util.ts12
1 files changed, 9 insertions, 3 deletions
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts
index 7c95769bb..95a5f1227 100644
--- a/editors/code/src/util.ts
+++ b/editors/code/src/util.ts
@@ -1,7 +1,6 @@
1import * as lc from "vscode-languageclient"; 1import * as lc from "vscode-languageclient";
2import * as vscode from "vscode"; 2import * as vscode from "vscode";
3import { strict as nativeAssert } from "assert"; 3import { strict as nativeAssert } from "assert";
4import { TextDocument } from "vscode";
5 4
6export function assert(condition: boolean, explanation: string): asserts condition { 5export function assert(condition: boolean, explanation: string): asserts condition {
7 try { 6 try {
@@ -67,9 +66,16 @@ function sleep(ms: number) {
67 return new Promise(resolve => setTimeout(resolve, ms)); 66 return new Promise(resolve => setTimeout(resolve, ms));
68} 67}
69 68
70export function isRustDocument(document: TextDocument) { 69export type RustDocument = vscode.TextDocument & { languageId: "rust" };
70export type RustEditor = vscode.TextEditor & { document: RustDocument; id: string };
71
72export function isRustDocument(document: vscode.TextDocument): document is RustDocument {
71 return document.languageId === 'rust' 73 return document.languageId === 'rust'
72 // SCM diff views have the same URI as the on-disk document but not the same content 74 // SCM diff views have the same URI as the on-disk document but not the same content
73 && document.uri.scheme !== 'git' 75 && document.uri.scheme !== 'git'
74 && document.uri.scheme !== 'svn'; 76 && document.uri.scheme !== 'svn';
75} \ No newline at end of file 77}
78
79export function isRustEditor(editor: vscode.TextEditor): editor is RustEditor {
80 return isRustDocument(editor.document);
81}