Skip to content

Commit bd90578

Browse files
authored
Merge pull request #269 from bollwyvl/interface/diagnostics_panel/fix-caret-icons
some tweaks to css, diagnostic icon for #258
2 parents 02f9f69 + cc30882 commit bd90578

File tree

10 files changed

+179
-40
lines changed

10 files changed

+179
-40
lines changed

docs/_static/css/custom.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ body div.nboutput.container div[class*='highlight'] pre {
3434
.wy-nav-content {
3535
max-width: 100%;
3636
}
37+
38+
.nbinput .prompt,
39+
.nboutput .prompt {
40+
display: none;
41+
}

docs/conf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"""{% block input -%}""" """{% if not cell.metadata.get("hide_input", False) -%}""",
1717
).replace("""{% endblock input %}""", """{%- endif -%}{%- endblock input %}""")
1818

19-
nbsphinx_prompt_width = "0"
2019

2120
sys.path.insert(
2221
0, str((pathlib.Path.cwd().parent / "py_src" / "jupyter_lsp").resolve())
@@ -27,7 +26,7 @@
2726
author = "Jupyter[Lab] Language Server Contributors"
2827

2928
version = "0.7.0"
30-
release = "0"
29+
release = ""
3130

3231
extensions = [
3332
"recommonmark",

packages/jupyterlab-lsp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"license": "BSD-3-Clause",
2020
"author": "Michał Krassowski",
2121
"files": [
22-
"{lib,style,schema,src}/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf,css,json,ts,tsx}"
22+
"{lib,style,schema,src}/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf,css,json,ts,tsx,txt,md}"
2323
],
2424
"main": "lib/index.js",
2525
"types": "lib/index.d.ts",

packages/jupyterlab-lsp/src/adapters/codemirror/features/diagnostics.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
DIAGNOSTICS_LISTING_CLASS,
1212
DiagnosticsDatabase,
1313
DiagnosticsListing,
14-
IEditorDiagnostic
14+
IEditorDiagnostic,
15+
diagnosticsIcon
1516
} from './diagnostics_listing';
1617
import { VirtualDocument } from '../../../virtual/document';
1718
import { VirtualEditor } from '../../../virtual/editor';
@@ -46,6 +47,7 @@ class DiagnosticsPanel {
4647
widget.id = 'lsp-diagnostics-panel';
4748
widget.title.label = 'Diagnostics Panel';
4849
widget.title.closable = true;
50+
widget.title.icon = diagnosticsIcon;
4951
return widget;
5052
}
5153

packages/jupyterlab-lsp/src/adapters/codemirror/features/diagnostics_listing.tsx

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { ReactElement } from 'react';
22
import { VDomModel, VDomRenderer } from '@jupyterlab/apputils';
3-
import { caretDownIcon, caretUpIcon } from '@jupyterlab/ui-components';
3+
import { caretDownIcon, caretUpIcon, LabIcon } from '@jupyterlab/ui-components';
44
import * as lsProtocol from 'vscode-languageserver-protocol';
55
import * as CodeMirror from 'codemirror';
66
import { IEditorPosition } from '../../../positioning';
@@ -13,6 +13,13 @@ import { Cell } from '@jupyterlab/cells';
1313
import { diagnosticSeverityNames } from '../../../lsp';
1414
import { message_without_code } from './diagnostics';
1515

16+
import diagnosticsSvg from '../../../../style/icons/diagnostics.svg';
17+
18+
export const diagnosticsIcon = new LabIcon({
19+
name: 'lsp:diagnostics',
20+
svgstr: diagnosticsSvg
21+
});
22+
1623
/**
1724
* Diagnostic which is localized at a specific editor (cell) within a notebook
1825
* (if used in the context of a FileEditor, then there is just a single editor)
@@ -163,17 +170,19 @@ class Column {
163170
function SortableTH(props: { name: string; listing: DiagnosticsListing }): any {
164171
const is_sort_key = props.name === props.listing.sort_key;
165172
const sortIcon =
166-
props.listing.sort_direction === 1 ? caretUpIcon : caretDownIcon;
173+
!is_sort_key || props.listing.sort_direction === 1
174+
? caretUpIcon
175+
: caretDownIcon;
167176
return (
168177
<th
169178
key={props.name}
170179
onClick={() => props.listing.sort(props.name)}
171180
className={is_sort_key ? 'lsp-sorted-header' : null}
172181
>
173-
{props.name}
174-
{is_sort_key ? (
182+
<div>
183+
<label>{props.name}</label>
175184
<sortIcon.react tag="span" className="lsp-sort-icon" />
176-
) : null}
185+
</div>
177186
</th>
178187
);
179188
}
@@ -230,19 +239,29 @@ export class DiagnosticsListing extends VDomRenderer<DiagnosticsListing.Model> {
230239
new Column({
231240
name: 'Cell',
232241
render_cell: row => <td key={5}>{row.cell_number}</td>,
233-
sort: (a, b) => (a.cell_number > b.cell_number ? 1 : -1),
242+
sort: (a, b) =>
243+
a.cell_number > b.cell_number
244+
? 1
245+
: a.data.range.start.line > b.data.range.start.line
246+
? 1
247+
: a.data.range.start.ch > b.data.range.start.ch
248+
? 1
249+
: -1,
234250
is_available: context => context.editor.has_cells
235251
}),
236252
new Column({
237-
name: 'Line',
238-
render_cell: row => <td key={6}>{row.data.range.start.line}</td>,
253+
name: 'Line:Ch',
254+
render_cell: row => (
255+
<td key={6}>
256+
{row.data.range.start.line}:{row.data.range.start.ch}
257+
</td>
258+
),
239259
sort: (a, b) =>
240-
a.data.range.start.line > b.data.range.start.line ? 1 : -1
241-
}),
242-
new Column({
243-
name: 'Ch',
244-
render_cell: row => <td key={7}>{row.data.range.start.line}</td>,
245-
sort: (a, b) => (a.data.range.start.ch > b.data.range.start.ch ? 1 : -1)
260+
a.data.range.start.line > b.data.range.start.line
261+
? 1
262+
: a.data.range.start.ch > b.data.range.start.ch
263+
? 1
264+
: -1
246265
})
247266
];
248267

packages/jupyterlab-lsp/src/typings.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@
22
// Distributed under the terms of the Modified BSD License.
33

44
/// <reference path="../typings/codemirror/codemirror.d.ts"/>
5+
6+
declare module '*.svg' {
7+
const script: string;
8+
export default script;
9+
}

packages/jupyterlab-lsp/style/diagnostics_listing.css

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@
1919
overflow-x: hidden;
2020
}
2121

22+
.lsp-diagnostics-listing th,
23+
.lsp-diagnostics-listing td {
24+
padding: 4px 12px 2px 12px;
25+
height: 18px;
26+
}
27+
2228
.lsp-diagnostics-listing th {
23-
padding: 4px 12px;
2429
font-weight: 500;
2530
text-align: left;
2631
border-bottom: var(--jp-border-width) solid var(--jp-border-color1);
@@ -44,38 +49,35 @@
4449
content: ' > ';
4550
}
4651

47-
.lsp-diagnostics-listing td:first-child,
48-
.lsp-diagnostics-listing td:last-child {
49-
padding: 4px 12px;
50-
}
51-
52-
.lsp-diagnostics-listing tbody td:not(:first-child):not(:last-child) {
53-
padding: 4px 2px;
54-
}
55-
5652
.lsp-diagnostics-listing tbody tr:hover {
5753
background: var(--jp-layout-color2);
5854
}
5955

60-
.lsp-sorted-header {
61-
flex: 0 0 auto;
62-
display: flex;
56+
.lsp-diagnostics-listing thead th > div {
6357
flex-direction: row;
64-
overflow: hidden;
58+
display: flex;
59+
}
60+
61+
.lsp-diagnostics-listing thead th > div > label {
62+
flex: 1;
63+
text-overflow: ellipsis;
6564
}
6665

6766
.lsp-sort-icon {
68-
top: -3px;
69-
left: 3px;
70-
position: relative;
71-
height: 16px;
72-
width: 16px;
73-
display: block;
74-
margin-left: auto;
67+
flex: 0;
68+
height: var(--jp-ui-font-size1);
69+
width: var(--jp-ui-font-size1);
7570
}
7671

7772
.lsp-sort-icon svg {
78-
width: 20px;
7973
display: inline;
8074
height: auto;
8175
}
76+
77+
.lsp-diagnostics-listing thead th:not(.lsp-sorted-header) .lsp-sort-icon {
78+
opacity: 0;
79+
}
80+
81+
.lsp-diagnostics-listing thead th:not(.lsp-sorted-header):hover .lsp-sort-icon {
82+
opacity: 0.5;
83+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
Copyright (c) 2014, Austin Andrews (http://materialdesignicons.com/),
2+
with Reserved Font Name Material Design Icons.
3+
Copyright (c) 2014, Google (http://www.google.com/design/)
4+
uses the license at https://github.com/google/material-design-icons/blob/master/LICENSE
5+
6+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
7+
This license is copied below, and is also available with a FAQ at:
8+
http://scripts.sil.org/OFL
9+
10+
11+
-----------------------------------------------------------
12+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
13+
-----------------------------------------------------------
14+
15+
PREAMBLE
16+
The goals of the Open Font License (OFL) are to stimulate worldwide
17+
development of collaborative font projects, to support the font creation
18+
efforts of academic and linguistic communities, and to provide a free and
19+
open framework in which fonts may be shared and improved in partnership
20+
with others.
21+
22+
The OFL allows the licensed fonts to be used, studied, modified and
23+
redistributed freely as long as they are not sold by themselves. The
24+
fonts, including any derivative works, can be bundled, embedded,
25+
redistributed and/or sold with any software provided that any reserved
26+
names are not used by derivative works. The fonts and derivatives,
27+
however, cannot be released under any other type of license. The
28+
requirement for fonts to remain under this license does not apply
29+
to any document created using the fonts or their derivatives.
30+
31+
DEFINITIONS
32+
"Font Software" refers to the set of files released by the Copyright
33+
Holder(s) under this license and clearly marked as such. This may
34+
include source files, build scripts and documentation.
35+
36+
"Reserved Font Name" refers to any names specified as such after the
37+
copyright statement(s).
38+
39+
"Original Version" refers to the collection of Font Software components as
40+
distributed by the Copyright Holder(s).
41+
42+
"Modified Version" refers to any derivative made by adding to, deleting,
43+
or substituting -- in part or in whole -- any of the components of the
44+
Original Version, by changing formats or by porting the Font Software to a
45+
new environment.
46+
47+
"Author" refers to any designer, engineer, programmer, technical
48+
writer or other person who contributed to the Font Software.
49+
50+
PERMISSION & CONDITIONS
51+
Permission is hereby granted, free of charge, to any person obtaining
52+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
53+
redistribute, and sell modified and unmodified copies of the Font
54+
Software, subject to the following conditions:
55+
56+
1) Neither the Font Software nor any of its individual components,
57+
in Original or Modified Versions, may be sold by itself.
58+
59+
2) Original or Modified Versions of the Font Software may be bundled,
60+
redistributed and/or sold with any software, provided that each copy
61+
contains the above copyright notice and this license. These can be
62+
included either as stand-alone text files, human-readable headers or
63+
in the appropriate machine-readable metadata fields within text or
64+
binary files as long as those fields can be easily viewed by the user.
65+
66+
3) No Modified Version of the Font Software may use the Reserved Font
67+
Name(s) unless explicit written permission is granted by the corresponding
68+
Copyright Holder. This restriction only applies to the primary font name as
69+
presented to the users.
70+
71+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
72+
Software shall not be used to promote, endorse or advertise any
73+
Modified Version, except to acknowledge the contribution(s) of the
74+
Copyright Holder(s) and the Author(s) or with their explicit written
75+
permission.
76+
77+
5) The Font Software, modified or unmodified, in part or in whole,
78+
must be distributed entirely under this license, and must not be
79+
distributed under any other license. The requirement for fonts to
80+
remain under this license does not apply to any document created
81+
using the Font Software.
82+
83+
TERMINATION
84+
This license becomes null and void if any of the above conditions are
85+
not met.
86+
87+
DISCLAIMER
88+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
89+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
90+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
91+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
92+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
93+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
94+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
95+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
96+
OTHER DEALINGS IN THE FONT SOFTWARE.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The following icons in this directory are open source, and are &copy; their
2+
respective license holders:
3+
4+
## Material Design Icons [OFL 1.1](<(./LICENSE.materialdesignicons.txt)>)
5+
6+
- [diagnostics.svg](./diagnostics.svg)
Lines changed: 5 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)