mirror of
https://github.com/tridactyl/tridactyl.git
synced 2026-09-10 07:16:33 -04:00
Merge pull request #5385 from GHolk/master
fix: js -d delimeter in arguments and visualenterauto in insert-mode
This commit is contained in:
commit
c02669a8f5
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -407,7 +407,7 @@ class HintState {
|
|||
}
|
||||
|
||||
/** @hidden*/
|
||||
let modeState: HintState
|
||||
export let modeState: HintState
|
||||
|
||||
interface Hintables {
|
||||
elements: Element[]
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) +
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue