mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
enable @filename parts within text, not just at end
This commit is contained in:
parent
342b747461
commit
f1f51b483b
1 changed files with 7 additions and 3 deletions
|
|
@ -51,10 +51,13 @@ export function Autocomplete(props: {
|
|||
})
|
||||
|
||||
function insertPart(text: string, part: PromptInfo["parts"][number]) {
|
||||
const append = "@" + text + " "
|
||||
const input = props.input()
|
||||
const currentCursorOffset = input.visualCursor.offset
|
||||
|
||||
const charAfterCursor = props.value.at(currentCursorOffset)
|
||||
const needsSpace = charAfterCursor !== " " && charAfterCursor !== undefined
|
||||
const append = "@" + text + (needsSpace ? " " : "")
|
||||
|
||||
input.cursorOffset = store.index
|
||||
const startCursor = input.logicalCursor
|
||||
input.cursorOffset = currentCursorOffset
|
||||
|
|
@ -316,8 +319,9 @@ export function Autocomplete(props: {
|
|||
}
|
||||
if (!store.visible) {
|
||||
if (e.name === "@") {
|
||||
const last = props.value.at(-1)
|
||||
if (last === " " || last === undefined) {
|
||||
const cursorOffset = props.input().visualCursor.offset
|
||||
const charBeforeCursor = cursorOffset === 0 ? undefined : props.value.at(cursorOffset - 1)
|
||||
if (charBeforeCursor === " " || charBeforeCursor === undefined) {
|
||||
show("@")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue