From 1de8349045f03b69907a1d7f3b2dda347d4a9733 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 3 Dec 2020 07:34:50 -0500 Subject: [PATCH] Fix hint helper in element picker's text editor Regression from: - https://github.com/gorhill/uBlock/commit/262a1a044f706d8937ba430911359d7c306329e4 --- src/js/1p-filters.js | 5 ++--- src/js/asset-viewer.js | 2 +- src/js/codemirror/ubo-static-filtering.js | 6 ++++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/js/1p-filters.js b/src/js/1p-filters.js index 647d48cdf..e02de5df2 100644 --- a/src/js/1p-filters.js +++ b/src/js/1p-filters.js @@ -61,12 +61,11 @@ let cachedUserFilters = ''; const responseHandler = function(response) { if ( response instanceof Object === false ) { return; } if ( response.hintUpdateToken !== undefined ) { - const firstVisit = hintUpdateToken === 0; const mode = cmEditor.getMode(); if ( mode.setHints instanceof Function ) { - mode.setHints(response, firstVisit); + mode.setHints(response); } - if ( firstVisit ) { + if ( hintUpdateToken === 0 ) { mode.parser.expertMode = response.expertMode !== false; } hintUpdateToken = response.hintUpdateToken; diff --git a/src/js/asset-viewer.js b/src/js/asset-viewer.js index 54fef4599..ecdef01c2 100644 --- a/src/js/asset-viewer.js +++ b/src/js/asset-viewer.js @@ -66,7 +66,7 @@ if ( hints instanceof Object ) { const mode = cmEditor.getMode(); if ( mode.setHints instanceof Function ) { - mode.setHints(hints, true); + mode.setHints(hints); } } diff --git a/src/js/codemirror/ubo-static-filtering.js b/src/js/codemirror/ubo-static-filtering.js index 78a8710c5..183af0909 100644 --- a/src/js/codemirror/ubo-static-filtering.js +++ b/src/js/codemirror/ubo-static-filtering.js @@ -35,6 +35,7 @@ const scriptletNames = new Map(); const preparseDirectiveTokens = new Map(); const preparseDirectiveHints = []; const originHints = []; +let hintHelperRegistered = false; /******************************************************************************/ @@ -361,7 +362,7 @@ CodeMirror.defineMode('ubo-static-filtering', function() { style = style.trim(); return style !== '' ? style : null; }, - setHints: function(details, firstVisit = false) { + setHints: function(details) { if ( Array.isArray(details.redirectResources) ) { for ( const [ name, desc ] of details.redirectResources ) { const displayText = desc.aliasOf !== '' @@ -389,7 +390,8 @@ CodeMirror.defineMode('ubo-static-filtering', function() { originHints.push(hint); } } - if ( firstVisit ) { + if ( hintHelperRegistered === false ) { + hintHelperRegistered = true; initHints(); } },