mirror of
https://github.com/fbarrca/obsidian-inlineAI.git
synced 2026-07-22 11:50:24 +00:00
This commit is contained in:
parent
46d6080ef3
commit
fc00ca701a
2 changed files with 6 additions and 4 deletions
|
|
@ -44,8 +44,8 @@ export default class InlineAIChatPlugin extends Plugin {
|
|||
setSelectionInfoEffect.of({ from, to, text: selectedText })
|
||||
);
|
||||
} else {
|
||||
// If no selection, you could clear it or do nothing
|
||||
effects.push(setSelectionInfoEffect.of(null));
|
||||
// If no selection, store cursor position instead of null
|
||||
effects.push(setSelectionInfoEffect.of({ from, to, text: "" }));
|
||||
}
|
||||
|
||||
// Also trigger the overlay
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@ const highlightDecoration = Decoration.mark({
|
|||
export const buildSelectionHiglightState = StateField.define<DecorationSet>({
|
||||
create(state) {
|
||||
const info = state.field(currentSelectionState);
|
||||
if (info) {
|
||||
if (info && info.from !== info.to) {
|
||||
console.log("info", info);
|
||||
return Decoration.set([highlightDecoration.range(info.from, info.to)]);
|
||||
}
|
||||
return Decoration.none;
|
||||
|
|
@ -59,7 +60,8 @@ export const buildSelectionHiglightState = StateField.define<DecorationSet>({
|
|||
update(decos, tr) {
|
||||
// Check if selectionInfoField has changed
|
||||
const info = tr.state.field(currentSelectionState);
|
||||
if (info) {
|
||||
if (info && info.from !== info.to) {
|
||||
console.log("info update", info);
|
||||
return Decoration.set([highlightDecoration.range(info.from, info.to)]);
|
||||
}
|
||||
return Decoration.none;
|
||||
|
|
|
|||
Loading…
Reference in a new issue