[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-11-21 Thread Lassi Väätämöinen
https://bugs.kde.org/show_bug.cgi?id=478303

Lassi Väätämöinen  changed:

   What|Removed |Added

 Status|NEEDSINFO   |CONFIRMED
 Ever confirmed|0   |1
 Resolution|FIXED   |---

-- 
You are receiving this mail because:
You are watching all bug changes.

[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-11-20 Thread Bug Janitor Service
https://bugs.kde.org/show_bug.cgi?id=478303

--- Comment #16 from Bug Janitor Service  ---
🐛🧹 ⚠️ This bug has been in NEEDSINFO status with no change for at least 15 days.
Please provide the requested information, then set the bug status to REPORTED.
If there is no change for at least 30 days, it will be automatically closed as
RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!

-- 
You are receiving this mail because:
You are watching all bug changes.

[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-11-06 Thread Lassi Väätämöinen
https://bugs.kde.org/show_bug.cgi?id=478303

--- Comment #15 from Lassi Väätämöinen  ---
Created attachment 175596
  --> https://bugs.kde.org/attachment.cgi?id=175596&action=edit
Kate: video about characers beign deleted after completion used

(In reply to Waqar Ahmed from comment #14)
> What do you mean by this, can you explain / show?

See attached video for demo.

The first completion is done after selecting the text 'lassi'.
Second completion is done on the empty following line, which shows what the
actual completion should be.

-- 
You are receiving this mail because:
You are watching all bug changes.

[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-11-06 Thread Waqar Ahmed
https://bugs.kde.org/show_bug.cgi?id=478303

--- Comment #14 from Waqar Ahmed  ---
> BUT: If you have pre-selected text, and just directly select from the 
> auto-complete box, the inserted result completion will have  characters 
> removed at the beginning of the line.

What do you mean by this, can you explain / show?

Also, would be great if you can try
https://invent.kde.org/utilities/kate/-/merge_requests/1644

-- 
You are receiving this mail because:
You are watching all bug changes.

[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-11-06 Thread Lassi Väätämöinen
https://bugs.kde.org/show_bug.cgi?id=478303

--- Comment #13 from Lassi Väätämöinen  ---
Created attachment 175595
  --> https://bugs.kde.org/attachment.cgi?id=175595&action=edit
Kate autocompletion settings

(In reply to Waqar Ahmed from comment #11)
> can you share a screenshot of your completion settings? (Editing ->
> Autocompletion)

Attached.

> Also, have you tried the bug with latest Kate? I can't reproduce the
> problems you are seeing. Our indenters got a lot better and a lot of other
> things changed in ktexteditor so this might have fixed this.

Seems to still occur. If you type one charcter, the typed character will erase
the pre-selected text (as is normal with editing any field or text).

BUT: If you have pre-selected text, and just directly select from the
auto-complete box, the inserted result completion will have  characters removed
at the beginning of the line.

-- 
You are receiving this mail because:
You are watching all bug changes.

[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-11-06 Thread Lassi Väätämöinen
https://bugs.kde.org/show_bug.cgi?id=478303

--- Comment #12 from Lassi Väätämöinen  ---
(In reply to Waqar Ahmed from comment #11)
> Also, have you tried the bug with latest Kate? I can't reproduce the
> problems you are seeing. Our indenters got a lot better and a lot of other
> things changed in ktexteditor so this might have fixed this.

I'll check when I have time. Just got my build working again yesterday, after a
while.

-- 
You are receiving this mail because:
You are watching all bug changes.

[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-11-06 Thread Waqar Ahmed
https://bugs.kde.org/show_bug.cgi?id=478303

Waqar Ahmed  changed:

   What|Removed |Added

 CC||waqar@gmail.com
 Status|REPORTED|NEEDSINFO
 Resolution|--- |FIXED

--- Comment #11 from Waqar Ahmed  ---
can you share a screenshot of your completion settings? (Editing ->
Autocompletion)

The code execute for when you manually click vs auto-completion is same. The
only thing that is different is the "word" being removed. In the case of
manual, nothing is removed, in auto complete case it _has_ to remove
_something_ as there might be partially typed data there.

Also, have you tried the bug with latest Kate? I can't reproduce the problems
you are seeing. Our indenters got a lot better and a lot of other things
changed in ktexteditor so this might have fixed this.

-- 
You are receiving this mail because:
You are watching all bug changes.

[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-11-04 Thread Christoph Cullmann
https://bugs.kde.org/show_bug.cgi?id=478303

--- Comment #10 from Christoph Cullmann  ---
(In reply to Lassi Väätämöinen from comment #9)
> (In reply to Christoph Cullmann from comment #8)
> > Could you try to fix that?
> 
> I guess it might be just the matter of duplicating the auto-completion
> snippet functionality with the functionality that the tool view has.
> Or better yet, the functionality code would be in one place, and both would
> execute the same code.
> 
> I think that was the problem I left this at; where should the common code go?

Good question, I have no good answer for that.

-- 
You are receiving this mail because:
You are watching all bug changes.

[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-11-04 Thread Lassi Väätämöinen
https://bugs.kde.org/show_bug.cgi?id=478303

--- Comment #9 from Lassi Väätämöinen  ---
(In reply to Christoph Cullmann from comment #8)
> Could you try to fix that?

I guess it might be just the matter of duplicating the auto-completion snippet
functionality with the functionality that the tool view has.
Or better yet, the functionality code would be in one place, and both would
execute the same code.

I think that was the problem I left this at; where should the common code go?

-- 
You are receiving this mail because:
You are watching all bug changes.

[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-11-02 Thread Christoph Cullmann
https://bugs.kde.org/show_bug.cgi?id=478303

Christoph Cullmann  changed:

   What|Removed |Added

 CC||christ...@cullmann.io

--- Comment #8 from Christoph Cullmann  ---
Could you try to fix that?

-- 
You are receiving this mail because:
You are watching all bug changes.

[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-07-11 Thread Lassi Väätämöinen
https://bugs.kde.org/show_bug.cgi?id=478303

--- Comment #7 from Lassi Väätämöinen  ---
(In reply to Lassi Väätämöinen from comment #6)
> Maybe these both should do it in more similar way?

Ah, missed this earlier; so for the keyboard completion popup is invoked from
KTextEditor side:

bool KateCompletionWidget::execute() {
...
model->executeCompletionItem(view(), *m_completionRanges[model].range,
toExecute);
... 
}


And then in snippetcompletionmodel.cpp:

void SnippetCompletionModel::executeCompletionItem(KTextEditor::View *view,
const KTextEditor::Range &word, const QModelIndex &index) const
{
if (index.parent().isValid()) {
m_snippets[index.row()]->execute(view, word);
}
}

Eventually running the same SnippetCompletionItem::execute(...) as the
mouse-selection path. But still, a bit differently.

-- 
You are receiving this mail because:
You are watching all bug changes.

[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-07-11 Thread Lassi Väätämöinen
https://bugs.kde.org/show_bug.cgi?id=478303

--- Comment #6 from Lassi Väätämöinen  ---
Snippet insertion in case of mouse click happens in snippetview.cpp:

void SnippetView::slotSnippetClicked(const QModelIndex &index)
{
QStandardItem *item =
SnippetStore::self()->itemFromIndex(m_proxy->mapToSource(index));
if (!item) {
return;
}

Snippet *snippet = Snippet::fromItem(item);
if (!snippet) {
return;
}

m_plugin->insertSnippet(snippet);
}


// And then in katesnippetglobal.cpp:

void KateSnippetGlobal::insertSnippet(Snippet *snippet)
{
// query active view, always prefer that!
KTextEditor::View *view =
KTextEditor::Editor::instance()->application()->activeMainWindow()->activeView();

// fallback to stuff set for dialog
if (!view) {
view = m_activeViewForDialog;
}

// no view => nothing to do
if (!view) {
return;
}

// try to insert snippet
SnippetCompletionItem item(snippet, static_cast(snippet->parent()));
item.execute(view, KTextEditor::Range(view->cursorPosition(),
view->cursorPosition()));

// set focus to view
view->setFocus();
}



In case of using the text completion for inserting the snippet, it looks
somewhat different in
snippetcompletionitem.cpp:

void SnippetCompletionItem::execute(KTextEditor::View *view, const
KTextEditor::Range &word)
{
// insert snippet content
view->insertTemplate(view->cursorPosition(), m_snippet, m_repo->script());
view->document()->removeText(word);
}



Maybe these both should do it in more similar way?

-- 
You are receiving this mail because:
You are watching all bug changes.

[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-07-11 Thread Lassi Väätämöinen
https://bugs.kde.org/show_bug.cgi?id=478303

--- Comment #5 from Lassi Väätämöinen  ---
Created attachment 171587
  --> https://bugs.kde.org/attachment.cgi?id=171587&action=edit
OK: insert at 1 space indent, same as the above text line indent

-- 
You are receiving this mail because:
You are watching all bug changes.

[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-07-11 Thread Lassi Väätämöinen
https://bugs.kde.org/show_bug.cgi?id=478303

--- Comment #4 from Lassi Väätämöinen  ---
Created attachment 171586
  --> https://bugs.kde.org/attachment.cgi?id=171586&action=edit
NOK: insert snipped at 2 spaces indent

-- 
You are receiving this mail because:
You are watching all bug changes.

[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-07-11 Thread Lassi Väätämöinen
https://bugs.kde.org/show_bug.cgi?id=478303

--- Comment #3 from Lassi Väätämöinen  ---
Created attachment 171585
  --> https://bugs.kde.org/attachment.cgi?id=171585&action=edit
NOK: insert with 0 spaces indent on current line

Also, this image shows the test snippet definition.

-- 
You are receiving this mail because:
You are watching all bug changes.

[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-07-11 Thread Lassi Väätämöinen
https://bugs.kde.org/show_bug.cgi?id=478303

--- Comment #2 from Lassi Väätämöinen  ---
Created attachment 171584
  --> https://bugs.kde.org/attachment.cgi?id=171584&action=edit
Inserted from pane with mouse: OK

-- 
You are receiving this mail because:
You are watching all bug changes.

[kate] [Bug 478303] Snippet output different when using Tool View and auto-complete

2024-07-11 Thread Lassi Väätämöinen
https://bugs.kde.org/show_bug.cgi?id=478303

--- Comment #1 from Lassi Väätämöinen  ---
OK, so the use case that causes the issue is identified. There's a bit of
difference how stuff works:

1. When snippet selected from the pane: regardless of how much the cursor has
been indented on an empty line (in a C++ code file), selecting a snippet from
the pane causes the line to be aligned to same indentation as the above line.

2. When snippet is inserted by using the completion pop-up, the error occurs if
the cursor is indented to any other position than the line above:
E.g. the above line is indented 1 space. Following scenarios:
- Insert snippet using completion, 0 space indent on the current line - NOK
- Insert snippet using completion, 1 space indent on the current line - OK
- Insert snippet using completion, 2 spaces indent on the current line - NOK

NOTE: In the "NOK" cases, the inserted snippet is anyhow adjusted to the
previous line indent depth: 1 space. But in these cases the inserting causes
wrong character sequence at the start of the text. This is NOT the case when
selecting from the side pane with mouse

-- 
You are receiving this mail because:
You are watching all bug changes.