Hi,
When opening context menu from the context menu key in keyboard, if there is no selection, the cursor jumps one line up.
Additional context:
- Goto https://phcode.dev/ , open any text file and click the keyboard right click button to repro the issue.
- The issue is only present in modern google chrome/edge browser. Its not present in Firefox, Safari, Edge/webkit Web views.
I did a bit of debugging and found the code below:
var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
It appears that the code always assumes context menu is opened with mouse. Is this a valid bug or am i doing something/config wrong at my end.
NB: resetSelectionOnContextMenu is set to true as it is expected behaviot
Below is the code fragment extracted from codemirror.js
TextareaInput.prototype.onContextMenu = function (e) {
var input = this, cm = input.cm, display = cm.display, te = input.textarea;
if (input.contextMenuPending) { input.contextMenuPending(); }
var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
if (!pos || presto) { return } // Opera is difficult.
// Reset the current text selection only if the click is done outside of the selection
// and 'resetSelectionOnContextMenu' option is true.
var reset = cm.options.resetSelectionOnContextMenu;
if (reset && cm.doc.sel.contains(pos) == -1)
{ operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); }
Thanks,
Arun