src/extensions/default/QuickView/main.js
function showPreview(editor, popover) {
        var token, cm;

        // Figure out which editor we are over
        if (!editor) {
            editor = getHoveredEditor(lastMousePos);
        }

        if (!editor || !editor._codeMirror) {
            hidePreview();
            return;
        }

        cm = editor._codeMirror;

        // Find char mouse is over
        var pos = cm.coordsChar({left: lastMousePos.clientX, top: lastMousePos.clientY});

        // No preview if mouse is past last char on line
        if (pos.ch >= editor.document.getLine(pos.line).length) {
            return;
        }

        if (popover) {
            popoverState = popover;
        } else {
            // Query providers and append to popoverState
            token = TokenUtils.getTokenAt(cm, pos);
            popoverState = $.extend({}, popoverState, queryPreviewProviders(editor, pos, token));
        }

        if (popoverState && popoverState.start && popoverState.end) {
            popoverState.marker = cm.markText(
                popoverState.start,
                popoverState.end,
                {className: "quick-view-highlight"}
            );

            $previewContent.append(popoverState.content);
            $previewContainer.show();

            popoverState.visible = true;

            if (popoverState.onShow) {
                popoverState.onShow();
            } else {
                positionPreview(editor, popoverState.xpos, popoverState.ytop, popoverState.ybot);
            }
        }
    }
function showPreview(editor, popover) {
        var token, cm;

        // Figure out which editor we are over
        if (!editor) {
            editor = getHoveredEditor(lastMousePos);
        }

        if (!editor || !editor._codeMirror) {
            hidePreview();
            return;
        }

        cm = editor._codeMirror;

        // Find char mouse is over
        var pos = cm.coordsChar({left: lastMousePos.clientX, top: lastMousePos.clientY});

        // No preview if mouse is past last char on line
        if (pos.ch >= editor.document.getLine(pos.line).length) {
            return;
        }

        if (popover) {
            popoverState = popover;
        } else {
            // Query providers and append to popoverState
            token = TokenUtils.getTokenAt(cm, pos);
            popoverState = $.extend({}, popoverState, queryPreviewProviders(editor, pos, token));
        }

        if (popoverState && popoverState.start && popoverState.end) {
            popoverState.marker = cm.markText(
                popoverState.start,
                popoverState.end,
                {className: "quick-view-highlight"}
            );

            $previewContent.append(popoverState.content);
            $previewContainer.show();

            popoverState.visible = true;

            if (popoverState.onShow) {
                popoverState.onShow();
            } else {
                positionPreview(editor, popoverState.xpos, popoverState.ytop, popoverState.ybot);
            }
        }
    }
function showPreview ( editor , popover ) { var token , cm ; // Figure out which editor we are over if ( ! editor ) { editor = getHoveredEditor ( lastMousePos ) ; } if ( ! editor || ! editor . _codeMirror ) { hidePreview ( ) ; return ; } cm = editor . _codeMirror ; // Find char mouse is over var pos = cm . coordsChar ( { left : lastMousePos . clientX , top : lastMousePos . clientY } ) ; // No preview if mouse is past last char on line if ( pos . ch >= editor . document . getLine ( pos . line ) . length ) { return ; } if ( popover ) { popoverState = popover ; } else { // Query providers and append to popoverState token = TokenUtils . getTokenAt ( cm , pos ) ; popoverState = $ . extend ( { } , popoverState , queryPreviewProviders ( editor , pos , token ) ) ; } if ( popoverState && popoverState . start && popoverState . end ) { popoverState . marker = cm . markText ( popoverState . start , popoverState . end , { className : "quick-view-highlight" } ) ; $previewContent . append ( popoverState . content ) ; $previewContainer . show ( ) ; popoverState . visible = true ; if ( popoverState . onShow ) { popoverState . onShow ( ) ; } else { positionPreview ( editor , popoverState . xpos , popoverState . ytop , popoverState . ybot ) ; } } }
Changes the current hidden popoverState to visible, showing it in the UI and highlighting
its matching text in the editor.
Changes the current hidden popoverState to visible showing it in the UI and highlighting its matching text in the editor .