Merge pull request #5385 from GHolk/master

fix: js -d delimeter in arguments and visualenterauto in insert-mode
This commit is contained in:
Oliver Blanthorn 2026-05-16 16:23:52 +00:00 committed by GitHub
commit c02669a8f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 40 additions and 13 deletions

View file

@ -451,13 +451,26 @@ document.addEventListener("selectionchange", () => {
contentState.mode = "normal"
return
}
if (
contentState.mode !== "normal" ||
config.get("visualenterauto") == "false"
)
// TODO: make use of submodeconfigs (excmds.setmode)
if (["ex", "ignore", "hint", "visual"].includes(contentState.mode)) {
return
if (!selection.isCollapsed) {
contentState.mode = "visual"
}
if (config.get("visualenterauto") == "false") return
if (!selection.isCollapsed) b: {
const text = selection.focusNode // text node or null
if (!text) break b
let element
if (text instanceof Element) element = text
else element = text.parentElement
if (
!element.isContentEditable ||
element.contentEditable === undefined // svg
) {
contentState.mode = "visual"
}
}
})

View file

@ -407,7 +407,7 @@ class HintState {
}
/** @hidden*/
let modeState: HintState
export let modeState: HintState
interface Hintables {
elements: Element[]

View file

@ -5955,13 +5955,15 @@ async function js_helper(str: string[]) {
break
}
const strJoin = str.join(" ")
if (separator !== null) {
const pos = strJoin.indexOf(separator)
// user may or may not use JS_ARGS
// eslint-disable-next-line @typescript-eslint/no-unused-vars
JS_ARGS = str.join(" ").split(separator)[1].split(" ")
jsContent = str.join(" ").split(separator)[0]
JS_ARGS = strJoin.slice(pos + 1).split(" ")
jsContent = strJoin.slice(0, pos)
} else {
jsContent = str.join(" ")
jsContent = strJoin
}
if (doSource) {

View file

@ -89,10 +89,22 @@ export const tab_insert = wrap_input((text, selectionStart, selectionEnd) => {
export const transpose_chars = wrap_input(
(text, selectionStart) => {
if (text.length < 2) return [null, null, null]
// When at the beginning of the text, transpose the first and second characters
const eolChars = ["\n", "\r"]
// When at the beginning of the text or line,
// transpose the first and second characters
if (selectionStart === 0) selectionStart = 1
// When at the end of the text, transpose the last and second-to-last characters
else if (eolChars.includes(text.charAt(selectionStart-1))) {
selectionStart += 1
}
// When at the end of the text or line,
// transpose the last and second-to-last characters
if (selectionStart >= text.length) selectionStart = text.length - 1
else if (eolChars.includes(text.charAt(selectionStart))) {
selectionStart -= 1
}
text =
text.substring(0, selectionStart - 1) +

View file

@ -45,7 +45,7 @@ export function parser(keys: MinimalKey[]) {
modeState.args,
].join(" ")
reset()
return { keys: [], exstr }
return { keys: [], exstr, isMatch: true }
}
const key = keys[0].key