mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 17:27:54 +00:00
chore(vscode-ide-companion): add qwen-code dependency to package files
This commit is contained in:
@@ -109,36 +109,12 @@ export function useCompletionTrigger(
|
||||
const handleInput = async () => {
|
||||
const text = inputElement.textContent || '';
|
||||
const selection = window.getSelection();
|
||||
|
||||
console.log(
|
||||
'[useCompletionTrigger] handleInput - text:',
|
||||
JSON.stringify(text),
|
||||
'length:',
|
||||
text.length,
|
||||
);
|
||||
|
||||
if (!selection || selection.rangeCount === 0) {
|
||||
console.log('[useCompletionTrigger] No selection or rangeCount === 0');
|
||||
return;
|
||||
}
|
||||
|
||||
const range = selection.getRangeAt(0);
|
||||
console.log(
|
||||
'[useCompletionTrigger] range.startContainer:',
|
||||
range.startContainer,
|
||||
'startOffset:',
|
||||
range.startOffset,
|
||||
);
|
||||
console.log(
|
||||
'[useCompletionTrigger] startContainer === inputElement:',
|
||||
range.startContainer === inputElement,
|
||||
);
|
||||
console.log(
|
||||
'[useCompletionTrigger] startContainer.nodeType:',
|
||||
range.startContainer.nodeType,
|
||||
'TEXT_NODE:',
|
||||
Node.TEXT_NODE,
|
||||
);
|
||||
|
||||
// Get cursor position more reliably
|
||||
// For contentEditable, we need to calculate the actual text offset
|
||||
@@ -157,14 +133,6 @@ export function useCompletionTrigger(
|
||||
offset += inputElement.childNodes[i].textContent?.length || 0;
|
||||
}
|
||||
cursorPosition = offset || text.length;
|
||||
console.log(
|
||||
'[useCompletionTrigger] Container mode - childIndex:',
|
||||
childIndex,
|
||||
'offset:',
|
||||
offset,
|
||||
'cursorPosition:',
|
||||
cursorPosition,
|
||||
);
|
||||
} else if (range.startContainer.nodeType === Node.TEXT_NODE) {
|
||||
// Cursor is in a text node - calculate offset from start of input
|
||||
const walker = document.createTreeWalker(
|
||||
@@ -187,40 +155,17 @@ export function useCompletionTrigger(
|
||||
}
|
||||
// If we found the node, use the calculated offset; otherwise use text length
|
||||
cursorPosition = found ? offset : text.length;
|
||||
console.log(
|
||||
'[useCompletionTrigger] Text node mode - found:',
|
||||
found,
|
||||
'offset:',
|
||||
offset,
|
||||
'cursorPosition:',
|
||||
cursorPosition,
|
||||
);
|
||||
}
|
||||
|
||||
// Find trigger character before cursor
|
||||
// Use text length if cursorPosition is 0 but we have text (edge case for first character)
|
||||
const effectiveCursorPosition =
|
||||
cursorPosition === 0 && text.length > 0 ? text.length : cursorPosition;
|
||||
console.log(
|
||||
'[useCompletionTrigger] cursorPosition:',
|
||||
cursorPosition,
|
||||
'effectiveCursorPosition:',
|
||||
effectiveCursorPosition,
|
||||
);
|
||||
|
||||
const textBeforeCursor = text.substring(0, effectiveCursorPosition);
|
||||
const lastAtMatch = textBeforeCursor.lastIndexOf('@');
|
||||
const lastSlashMatch = textBeforeCursor.lastIndexOf('/');
|
||||
|
||||
console.log(
|
||||
'[useCompletionTrigger] textBeforeCursor:',
|
||||
JSON.stringify(textBeforeCursor),
|
||||
'lastAtMatch:',
|
||||
lastAtMatch,
|
||||
'lastSlashMatch:',
|
||||
lastSlashMatch,
|
||||
);
|
||||
|
||||
// Check if we're in a trigger context
|
||||
let triggerPos = -1;
|
||||
let triggerChar: '@' | '/' | null = null;
|
||||
@@ -233,46 +178,19 @@ export function useCompletionTrigger(
|
||||
triggerChar = '/';
|
||||
}
|
||||
|
||||
console.log(
|
||||
'[useCompletionTrigger] triggerPos:',
|
||||
triggerPos,
|
||||
'triggerChar:',
|
||||
triggerChar,
|
||||
);
|
||||
|
||||
// Check if trigger is at word boundary (start of line or after space)
|
||||
if (triggerPos >= 0 && triggerChar) {
|
||||
const charBefore = triggerPos > 0 ? text[triggerPos - 1] : ' ';
|
||||
const isValidTrigger =
|
||||
charBefore === ' ' || charBefore === '\n' || triggerPos === 0;
|
||||
|
||||
console.log(
|
||||
'[useCompletionTrigger] charBefore:',
|
||||
JSON.stringify(charBefore),
|
||||
'isValidTrigger:',
|
||||
isValidTrigger,
|
||||
);
|
||||
|
||||
if (isValidTrigger) {
|
||||
const query = text.substring(triggerPos + 1, effectiveCursorPosition);
|
||||
|
||||
console.log(
|
||||
'[useCompletionTrigger] query:',
|
||||
JSON.stringify(query),
|
||||
'hasSpace:',
|
||||
query.includes(' '),
|
||||
'hasNewline:',
|
||||
query.includes('\n'),
|
||||
);
|
||||
|
||||
// Only show if query doesn't contain spaces (still typing the reference)
|
||||
if (!query.includes(' ') && !query.includes('\n')) {
|
||||
// Get precise cursor position for menu
|
||||
const cursorPos = getCursorPosition();
|
||||
console.log(
|
||||
'[useCompletionTrigger] Opening completion - cursorPos:',
|
||||
cursorPos,
|
||||
);
|
||||
if (cursorPos) {
|
||||
await openCompletion(triggerChar, query, cursorPos);
|
||||
return;
|
||||
@@ -282,10 +200,6 @@ export function useCompletionTrigger(
|
||||
}
|
||||
|
||||
// Close if no valid trigger
|
||||
console.log(
|
||||
'[useCompletionTrigger] No valid trigger, state.isOpen:',
|
||||
state.isOpen,
|
||||
);
|
||||
if (state.isOpen) {
|
||||
closeCompletion();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user