mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 04:16:00 +00:00
using gutte3r decorations for active query part
This commit is contained in:
@@ -307,18 +307,14 @@
|
|||||||
if (!mode?.includes('sql')) return;
|
if (!mode?.includes('sql')) return;
|
||||||
|
|
||||||
editor?.session?.setAnnotations([
|
editor?.session?.setAnnotations([
|
||||||
...currentPartLines.map(row => ({
|
|
||||||
row,
|
|
||||||
className: 'ace-gutter-current-part',
|
|
||||||
})),
|
|
||||||
...(queryParts || [])
|
...(queryParts || [])
|
||||||
.filter(part => !(errorMessages || []).find(err => err.line == part.trimStart?.line))
|
.filter(part => !(errorMessages || []).find(err => err.line == part.trimStart.line))
|
||||||
.map(part => ({
|
.map(part => ({
|
||||||
row: part.trimStart.line,
|
row: part.trimStart.line,
|
||||||
text: part.text,
|
text: part.text,
|
||||||
className: currentPartLines.includes(part.trimStart.line)
|
className: currentPartLines.includes(part.trimStart.line)
|
||||||
? 'ace-gutter-sql-run ace-gutter-current-part'
|
? 'ace-gutter-sql-run ace-gutter-current-part'
|
||||||
: 'ace-gutter-sql-run',
|
: 'ace-gutter-sql-run', // className: 'ace-gutter-sql-run',
|
||||||
})),
|
})),
|
||||||
...(errorMessages || []).map(error => ({
|
...(errorMessages || []).map(error => ({
|
||||||
row: error.line,
|
row: error.line,
|
||||||
@@ -369,10 +365,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function changedCurrentQueryPart() {
|
function changedCurrentQueryPart() {
|
||||||
// if (queryParts.length <= 1) {
|
if (queryParts.length <= 1) {
|
||||||
// removeCurrentPartMarker();
|
removeCurrentPartMarker();
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
const selectionRange = editor.getSelectionRange();
|
const selectionRange = editor.getSelectionRange();
|
||||||
|
|
||||||
@@ -393,15 +389,20 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (part?.text != currentPart?.text || part?.start?.position != currentPart?.start?.position) {
|
if (part?.text != currentPart?.text || part?.start?.position != currentPart?.start?.position) {
|
||||||
// removeCurrentPartMarker();
|
removeCurrentPartMarker();
|
||||||
|
|
||||||
currentPart = part;
|
currentPart = part;
|
||||||
currentPartLines = [];
|
|
||||||
if (currentPart) {
|
if (currentPart) {
|
||||||
const start = currentPart.trimStart || currentPart.start;
|
const start = currentPart.trimStart || currentPart.start;
|
||||||
const end = currentPart.trimEnd || currentPart.end;
|
const end = currentPart.trimEnd || currentPart.end;
|
||||||
if (start && end) {
|
if (start && end) {
|
||||||
currentPartLines = _.range(start.line, end.line + 1);
|
currentPartLines = _.range(start.line, end.line + 1);
|
||||||
|
for (const row of currentPartLines) {
|
||||||
|
if ((queryParts || []).find(part => part.trimStart.line == row)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
editor.getSession().addGutterDecoration(row, 'ace-gutter-current-part');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// currentPartMarker = editor
|
// currentPartMarker = editor
|
||||||
// .getSession()
|
// .getSession()
|
||||||
@@ -411,12 +412,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// function removeCurrentPartMarker() {
|
function removeCurrentPartMarker() {
|
||||||
// if (currentPartMarker != null) {
|
for (const row of currentPartLines) {
|
||||||
// editor.getSession().removeMarker(currentPartMarker);
|
editor.getSession().removeGutterDecoration(row, 'ace-gutter-current-part');
|
||||||
// currentPartMarker = null;
|
}
|
||||||
// }
|
currentPartLines = [];
|
||||||
// }
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
editor = ace.edit(EDITOR_ID);
|
editor = ace.edit(EDITOR_ID);
|
||||||
|
|||||||
Reference in New Issue
Block a user