suggestion
When editing JS files, typing "window." triggers intellisense and
automatically selects the first suggestion ("window.AbortController")
The AI model would then use this default selection to insert a
completion without user input.
This commit updates the logic so that AI autocompletion only triggers
once the user has typed a few characters beyond the default suggestion,
ensuring that unwanted completions are not inserted early.
The original behavior was only selecting the highlighted part
and if there is nothing selected in the trailing line it still
got seleced to the edit mode. This fix is to expand the
selection start to the very beginning of first line and the
selection end to the very end of the last line. In addtion,
prevent the trailing line getting selecting if there is
nothing in it.
https://github.com/Granite-Code/granite-code/issues/42
The original behavior selects the entire first line even though it's
only partially selected in the editor. This fix is to get rid of the
extra selection from the first line and only send the exact part that
gets selected in the editor to the chat section. However, there is an
exception that if the context before the start of the selection
contains only whitespace, we want to include the wihitespace into the
selection because it's the indentation.
https://github.com/Granite-Code/granite-code/issues/43
When switching to the edit mode and we make a selection of code, it
needs to appear above the highlighting not be obscured by it. In this
fix, instead of using an opaque background colour for the highlighting
decoration, we use a highlighting with opacity so that the selected
code is visible below it
myersDiff inherits the jsdiff behavior for trailing \n, so would
consider "foo\n" => "foo" a changed single line, rather than a change
from "foo", "" to "foo" - this would result in a trailing blank line
in the highlighted region silently vanishing from the buffer.
Adding \n to the inputs so that lines are \n terminated rather than
separated fixes this.
To make myersDiff logically consistent, pass ignoreNewlineAtEof: true
to jsdiff. (This is actually not needed for this bug fix.)