MCPcopy
hub / github.com/witheve/Eve / handleExternalSelection

Function handleExternalSelection

src/codemirror.js:14253–14281  ·  view source on GitHub ↗
(cm, vim)

Source from the content-addressed store, hash-verified

14251 vim.fakeCursor = cm.markText(from, to, {className: 'cm-animate-fat-cursor'});
14252 }
14253 function handleExternalSelection(cm, vim) {
14254 var anchor = cm.getCursor('anchor');
14255 var head = cm.getCursor('head');
14256 // Enter or exit visual mode to match mouse selection.
14257 if (vim.visualMode && !cm.somethingSelected()) {
14258 exitVisualMode(cm, false);
14259 } else if (!vim.visualMode && !vim.insertMode && cm.somethingSelected()) {
14260 vim.visualMode = true;
14261 vim.visualLine = false;
14262 CodeMirror.signal(cm, "vim-mode-change", {mode: "visual"});
14263 }
14264 if (vim.visualMode) {
14265 // Bind CodeMirror selection model to vim selection model.
14266 // Mouse selections are considered visual characterwise.
14267 var headOffset = !cursorIsBefore(head, anchor) ? -1 : 0;
14268 var anchorOffset = cursorIsBefore(head, anchor) ? -1 : 0;
14269 head = offsetCursor(head, 0, headOffset);
14270 anchor = offsetCursor(anchor, 0, anchorOffset);
14271 vim.sel = {
14272 anchor: anchor,
14273 head: head
14274 };
14275 updateMark(cm, vim, '<', cursorMin(head, anchor));
14276 updateMark(cm, vim, '>', cursorMax(head, anchor));
14277 } else if (!vim.insertMode) {
14278 // Reset lastHPos if selection was modified by something outside of vim mode e.g. by mouse.
14279 vim.lastHPos = cm.getCursor().ch;
14280 }
14281 }
14282
14283 /** Wrapper for special keys pressed in insert mode */
14284 function InsertModeKey(keyName) {

Callers 1

onCursorActivityFunction · 0.85

Calls 8

exitVisualModeFunction · 0.85
cursorIsBeforeFunction · 0.85
offsetCursorFunction · 0.85
updateMarkFunction · 0.85
cursorMinFunction · 0.85
cursorMaxFunction · 0.85
getCursorMethod · 0.80
somethingSelectedMethod · 0.80

Tested by

no test coverage detected