tvl-depot/third_party/gerrit/0003-Syntax-highlight-rules.pl.patch
Luke Granger-Brown 021d688ccc chore(gerrit): update to 3.2.2
Change-Id: Ia41e19250f9f900c73904553a931f0f4dde3a5bf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/860
Tested-by: BuildkiteCI
Reviewed-by: Kane York <rikingcoding@gmail.com>
Reviewed-by: tazjin <mail@tazj.in>
Reviewed-by: isomer <isomer@tvl.fyi>
2020-07-10 18:50:13 +00:00

44 lines
1.4 KiB
Diff

From 0e4599e43c0f57c7636af3b8b384c212e1700351 Mon Sep 17 00:00:00 2001
From: Luke Granger-Brown <git@lukegb.com>
Date: Thu, 2 Jul 2020 23:02:43 +0100
Subject: [PATCH 3/4] Syntax highlight rules.pl
---
.../elements/diff/gr-syntax-layer/gr-syntax-layer.js | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js
index cc937cff67..2145bc169b 100644
--- a/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js
+++ b/polygerrit-ui/app/elements/diff/gr-syntax-layer/gr-syntax-layer.js
@@ -105,6 +105,10 @@ const LANGUAGE_MAP = {
};
const ASYNC_DELAY = 10;
+const FILENAME_OVERRIDES = {
+ 'rules.pl': 'prolog',
+};
+
const CLASS_WHITELIST = {
'gr-diff gr-syntax gr-syntax-attr': true,
'gr-diff gr-syntax gr-syntax-attribute': true,
@@ -236,10 +240,16 @@ class GrSyntaxLayer extends GestureEventListeners(
}
}
+ _basename(filename) {
+ const pieces = filename.split(/\//);
+ return pieces[pieces.length-1];
+ }
+
_getLanguage(diffFileMetaInfo) {
// The Gerrit API provides only content-type, but for other users of
// gr-diff it may be more convenient to specify the language directly.
return diffFileMetaInfo.language ||
+ FILENAME_OVERRIDES[this._basename(diffFileMetaInfo.name)] ||
LANGUAGE_MAP[diffFileMetaInfo.content_type];
}
--
2.25.1