mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 04:59:22 -06:00
FIX: Allow backspace into hashtag autocomplete (#19489)
Way back in90100378b8
when we first added hashtag autocompletion, we added a rule to say we should not trigger autocomplete when backspacing into a hashtag. I think this is because we used to also not trigger it at the start of the line because of how markdown headers used to work. We removed this rule in6f0b9bb1c4
so we are safe to remove the backspace exception here too. Now you can backspace into a hashtag to trigger the autocomplete.
This commit is contained in:
parent
dcc9611aec
commit
98e3e90aa2
@ -7,7 +7,6 @@ import { ajax } from "discourse/lib/ajax";
|
||||
import discourseDebounce from "discourse-common/lib/debounce";
|
||||
import {
|
||||
caretPosition,
|
||||
caretRowCol,
|
||||
escapeExpression,
|
||||
inCodeBlock,
|
||||
} from "discourse/lib/utilities";
|
||||
@ -54,20 +53,7 @@ export function setupHashtagAutocomplete(
|
||||
}
|
||||
}
|
||||
|
||||
export function hashtagTriggerRule(textarea, opts) {
|
||||
const result = caretRowCol(textarea);
|
||||
const row = result.rowNum;
|
||||
let line = textarea.value.split("\n")[row - 1];
|
||||
|
||||
if (opts && opts.backSpace) {
|
||||
line = line.slice(0, line.length - 1);
|
||||
|
||||
// Don't trigger autocomplete when backspacing into a `#category |` => `#category|`
|
||||
if (/^#{1}\w+/.test(line)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function hashtagTriggerRule(textarea) {
|
||||
if (inCodeBlock(textarea.value, caretPosition(textarea))) {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user