mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
4625: Partially fix displaying inlay hints in Github PR diff views r=matklad a=Veetaha See the comment in https://github.com/rust-analyzer/rust-analyzer/issues/4608#issuecomment-63424257 It partially fixes the left side of diff view (the one where old code is displayed), but the diff editor with new code changes still has `file` scheme and will proceed displaying inlay hints... 4629: Fix the `should_panic` snippet r=matklad a=eminence Closes #4628 Co-authored-by: veetaha <veetaha2@gmail.com> Co-authored-by: Andrew Chin <achin@eminence32.net>
This commit is contained in:
commit
3c5112b079
2 changed files with 8 additions and 7 deletions
|
@ -112,7 +112,7 @@ const ATTRIBUTES: &[AttrCompletion] = &[
|
||||||
AttrCompletion { label: "repr", snippet: Some("repr(${0:C})"), should_be_inner: false },
|
AttrCompletion { label: "repr", snippet: Some("repr(${0:C})"), should_be_inner: false },
|
||||||
AttrCompletion {
|
AttrCompletion {
|
||||||
label: "should_panic",
|
label: "should_panic",
|
||||||
snippet: Some(r#"expected = "${0:reason}""#),
|
snippet: Some(r#"should_panic(expected = "${0:reason}")"#),
|
||||||
should_be_inner: false,
|
should_be_inner: false,
|
||||||
},
|
},
|
||||||
AttrCompletion {
|
AttrCompletion {
|
||||||
|
@ -571,7 +571,7 @@ mod tests {
|
||||||
label: "should_panic",
|
label: "should_panic",
|
||||||
source_range: 19..19,
|
source_range: 19..19,
|
||||||
delete: 19..19,
|
delete: 19..19,
|
||||||
insert: "expected = \"${0:reason}\"",
|
insert: "should_panic(expected = \"${0:reason}\")",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
|
@ -810,7 +810,7 @@ mod tests {
|
||||||
label: "should_panic",
|
label: "should_panic",
|
||||||
source_range: 20..20,
|
source_range: 20..20,
|
||||||
delete: 20..20,
|
delete: 20..20,
|
||||||
insert: "expected = \"${0:reason}\"",
|
insert: "should_panic(expected = \"${0:reason}\")",
|
||||||
kind: Attribute,
|
kind: Attribute,
|
||||||
},
|
},
|
||||||
CompletionItem {
|
CompletionItem {
|
||||||
|
|
|
@ -74,10 +74,11 @@ export type RustDocument = vscode.TextDocument & { languageId: "rust" };
|
||||||
export type RustEditor = vscode.TextEditor & { document: RustDocument };
|
export type RustEditor = vscode.TextEditor & { document: RustDocument };
|
||||||
|
|
||||||
export function isRustDocument(document: vscode.TextDocument): document is RustDocument {
|
export function isRustDocument(document: vscode.TextDocument): document is RustDocument {
|
||||||
return document.languageId === 'rust'
|
// Prevent corrupted text (particularly via inlay hints) in diff views
|
||||||
// SCM diff views have the same URI as the on-disk document but not the same content
|
// by allowing only `file` schemes
|
||||||
&& document.uri.scheme !== 'git'
|
// unfortunately extensions that use diff views not always set this
|
||||||
&& document.uri.scheme !== 'svn';
|
// to something different than 'file' (see ongoing bug: #4608)
|
||||||
|
return document.languageId === 'rust' && document.uri.scheme === 'file';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isRustEditor(editor: vscode.TextEditor): editor is RustEditor {
|
export function isRustEditor(editor: vscode.TextEditor): editor is RustEditor {
|
||||||
|
|
Loading…
Reference in a new issue