[css][html] Option to disable MDN Reference popups only (without effecting other functionalities). For #97979

This commit is contained in:
Martin Aeschlimann 2020-11-30 23:25:42 +01:00
parent c6e90c5ea3
commit dceba9ebb7
7 changed files with 34 additions and 18 deletions

View file

@ -187,6 +187,18 @@
"default": true,
"description": "%html.autoClosingTags%"
},
"html.hover.documentation": {
"type": "boolean",
"scope": "resource",
"default": true,
"description": "%html.hover.documentation%"
},
"html.hover.references": {
"type": "boolean",
"scope": "resource",
"default": true,
"description": "%html.hover.references%"
},
"html.mirrorCursorOnMatchingTag": {
"type": "boolean",
"scope": "resource",

View file

@ -29,5 +29,7 @@
"html.validate.styles": "Controls whether the built-in HTML language support validates embedded styles.",
"html.autoClosingTags": "Enable/disable autoclosing of HTML tags.",
"html.mirrorCursorOnMatchingTag": "Enable/disable mirroring cursor on matching HTML tag.",
"html.mirrorCursorOnMatchingTagDeprecationMessage": "Deprecated in favor of `editor.linkedEditing`"
"html.mirrorCursorOnMatchingTagDeprecationMessage": "Deprecated in favor of `editor.linkedEditing`",
"html.hover.documentation": "Show tag and attribute documentation in hover.",
"html.hover.references": "Show references to MDN in hover."
}

View file

@ -9,8 +9,8 @@
},
"main": "./out/node/htmlServerMain",
"dependencies": {
"vscode-css-languageservice": "^4.3.5",
"vscode-html-languageservice": "^3.1.5",
"vscode-css-languageservice": "^4.3.6",
"vscode-html-languageservice": "^3.2.0",
"vscode-languageserver": "7.0.0-next.3",
"vscode-nls": "^5.0.0",
"vscode-uri": "^2.1.2"

View file

@ -284,7 +284,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
if (!mode || !mode.doComplete) {
return { isIncomplete: true, items: [] };
}
const doComplete = mode.doComplete!;
const doComplete = mode.doComplete;
if (mode.getId() !== 'html') {
/* __GDPR__
@ -321,8 +321,10 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
const document = documents.get(textDocumentPosition.textDocument.uri);
if (document) {
const mode = languageModes.getModeAtPosition(document, textDocumentPosition.position);
if (mode && mode.doHover) {
return mode.doHover(document, textDocumentPosition.position);
const doHover = mode?.doHover;
if (doHover) {
const settings = await getDocumentSettings(document, () => doHover.length > 2);
return doHover(document, textDocumentPosition.position, settings);
}
}
return null;

View file

@ -8,7 +8,7 @@ import {
LanguageService as HTMLLanguageService, HTMLDocument, DocumentContext, FormattingOptions,
HTMLFormatConfiguration, SelectionRange,
TextDocument, Position, Range, FoldingRange,
LanguageMode, Workspace
LanguageMode, Workspace, Settings
} from './languageModes';
export function getHTMLMode(htmlLanguageService: HTMLLanguageService, workspace: Workspace): LanguageMode {
@ -31,8 +31,8 @@ export function getHTMLMode(htmlLanguageService: HTMLLanguageService, workspace:
let completionList = htmlLanguageService.doComplete2(document, position, htmlDocument, documentContext, options);
return completionList;
},
async doHover(document: TextDocument, position: Position) {
return htmlLanguageService.doHover(document, position, htmlDocuments.get(document));
async doHover(document: TextDocument, position: Position, settings?: Settings) {
return htmlLanguageService.doHover(document, position, htmlDocuments.get(document), settings?.html?.hover);
},
async findDocumentHighlight(document: TextDocument, position: Position) {
return htmlLanguageService.findDocumentHighlights(document, position, htmlDocuments.get(document));

View file

@ -45,7 +45,7 @@ export interface LanguageMode {
doValidation?: (document: TextDocument, settings?: Settings) => Promise<Diagnostic[]>;
doComplete?: (document: TextDocument, position: Position, documentContext: DocumentContext, settings?: Settings) => Promise<CompletionList>;
doResolve?: (document: TextDocument, item: CompletionItem) => Promise<CompletionItem>;
doHover?: (document: TextDocument, position: Position) => Promise<Hover | null>;
doHover?: (document: TextDocument, position: Position, settings?: Settings) => Promise<Hover | null>;
doSignatureHelp?: (document: TextDocument, position: Position) => Promise<SignatureHelp | null>;
doRename?: (document: TextDocument, position: Position, newName: string) => Promise<WorkspaceEdit | null>;
doLinkedEditing?: (document: TextDocument, position: Position) => Promise<Range[] | null>;

View file

@ -880,20 +880,20 @@ to-regex-range@^5.0.1:
dependencies:
is-number "^7.0.0"
vscode-css-languageservice@^4.3.5:
version "4.3.5"
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-4.3.5.tgz#92f8817057dee7c381df2289aad539c7b553548a"
integrity sha512-g9Pjxt9T32jhY0nTOo7WRFm0As27IfdaAxcFa8c7Rml1ZqBn3XXbkExjzxY7sBWYm7I1Tp4dK6UHXHoUQHGwig==
vscode-css-languageservice@^4.3.6:
version "4.3.6"
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-4.3.6.tgz#0e37c2d47724f895f36e1aad7e0a8f121591b22f"
integrity sha512-0xjY6ocBqDPbjHRqahWWE+AFtBb1LgO0PN9L2M0fY5IcsU2Eo/V2f/zrntIekXIYQl4cHS0XRkL7ZXSO6s19oA==
dependencies:
vscode-languageserver-textdocument "^1.0.1"
vscode-languageserver-types "3.16.0-next.2"
vscode-nls "^5.0.0"
vscode-uri "^2.1.2"
vscode-html-languageservice@^3.1.5:
version "3.1.5"
resolved "https://registry.yarnpkg.com/vscode-html-languageservice/-/vscode-html-languageservice-3.1.5.tgz#80e8c4f90befc0941265942603c74c5c81dcee58"
integrity sha512-+1Ofik//yQLeot8foOCMoM4IX0+mpSEEooO8HZyUkOPJbvMlBbEQ/3+39EOFpXSoSE1wCmuaffkMRI2NqgoPfA==
vscode-html-languageservice@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/vscode-html-languageservice/-/vscode-html-languageservice-3.2.0.tgz#e92269a04097d87bd23431e3a4e491a27b5447b9"
integrity sha512-aLWIoWkvb5HYTVE0kI9/u3P0ZAJGrYOSAAE6L0wqB9radKRtbJNrF9+BjSUFyCgBdNBE/GFExo35LoknQDJrfw==
dependencies:
vscode-languageserver-textdocument "^1.0.1"
vscode-languageserver-types "3.16.0-next.2"