Skip to content

Commit

Permalink
Tooltip fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Mar 22, 2023
1 parent acf053b commit 0bb3dc6
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions website/src/js/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { PHPStanError } from './PHPStanError';
import { ttcn } from './ttcn-theme';

const buildErrorLines = (doc: Text, lines: number[]) => {
const errorLineDecoration = Decoration.line({class: 'bg-red-200/50 hover:bg-red-300/50'});
const errorLineDecoration = Decoration.line({class: 'bg-red-200/50'});
const builder = new RangeSetBuilder<Decoration>();
for (let i = 0; i < doc.lines; i++) {
const line = doc.line(i + 1);
Expand Down Expand Up @@ -41,6 +41,7 @@ ko.bindingHandlers.codeMirror = {
}

const hover = hoverTooltip((view, pos, side) => {
console.log('here');

This comment has been minimized.

Copy link
@herndlm

herndlm Mar 22, 2023

Contributor

Jfyi, not sure if on purpose or not, but you left this in apparently :)

This comment has been minimized.

Copy link
@ondrejmirtes

ondrejmirtes Mar 22, 2023

Author Member

Oh god 😊 thanks

const currentErrors: PHPStanError[] = allBindings.get('codeMirrorErrors');
const line = view.state.doc.lineAt(pos);
const lineErrors: string[] = [];
Expand All @@ -54,8 +55,17 @@ ko.bindingHandlers.codeMirror = {
return null;
}

let from = line.from;
while (from < line.to && /\s/.test(line.text[from - line.from])) {
from++
}

if (from === line.to) {
from = line.from
}

return {
pos: line.from,
pos: from,
end: line.to,
above: true,
create() {
Expand Down Expand Up @@ -142,6 +152,11 @@ ko.bindingHandlers.codeMirror = {
errorLines,
hover,
ttcn,
EditorView.baseTheme({
'.cm-tooltip.cm-tooltip-hover': {
border: 'none',
},
}),
],
})

Expand Down

0 comments on commit 0bb3dc6

Please sign in to comment.