@@ -1536,6 +1536,86 @@ pub fn goto_reference(cx: &mut Context) {
15361536 );
15371537}
15381538
1539+fn goto_pos(editor: &mut Editor, pos: usize) {
1540+ push_jump(editor);
1541+
1542+ let (view, doc) = editor.current();
1543+
1544+ doc.set_selection(view.id, Selection::point(pos));
1545+ align_view(doc, view, Align::Center);
1546+}
1547+
1548+pub fn goto_first_diag(cx: &mut Context) {
1549+ let editor = &mut cx.editor;
1550+ let (view, doc) = editor.current();
1551+
1552+ let cursor_pos = doc.selection(view.id).cursor();
1553+ let diag = if let Some(diag) = doc.diagnostics().first() {
1554+ diag.range.start
1555+ } else {
1556+ return;
1557+ };
1558+
1559+ goto_pos(editor, diag);
1560+}
1561+
1562+pub fn goto_last_diag(cx: &mut Context) {
1563+ let editor = &mut cx.editor;
1564+ let (view, doc) = editor.current();
1565+
1566+ let cursor_pos = doc.selection(view.id).cursor();
1567+ let diag = if let Some(diag) = doc.diagnostics().last() {
1568+ diag.range.start
1569+ } else {
1570+ return;
1571+ };
1572+
1573+ goto_pos(editor, diag);
1574+}
1575+
1576+pub fn goto_next_diag(cx: &mut Context) {
1577+ let editor = &mut cx.editor;
1578+ let (view, doc) = editor.current();
1579+
1580+ let cursor_pos = doc.selection(view.id).cursor();
1581+ let diag = if let Some(diag) = doc
1582+ .diagnostics()
1583+ .iter()
1584+ .map(|diag| diag.range.start)
1585+ .find(|&pos| pos > cursor_pos)
1586+ {
1587+ diag
1588+ } else if let Some(diag) = doc.diagnostics().first() {
1589+ diag.range.start
1590+ } else {
1591+ return;
1592+ };
1593+
1594+ goto_pos(editor, diag);
1595+}
1596+
1597+pub fn goto_prev_diag(cx: &mut Context) {
1598+ let editor = &mut cx.editor;
1599+ let (view, doc) = editor.current();
1600+
1601+ let cursor_pos = doc.selection(view.id).cursor();
1602+ let diag = if let Some(diag) = doc
1603+ .diagnostics()
1604+ .iter()
1605+ .rev()
1606+ .map(|diag| diag.range.start)
1607+ .find(|&pos| pos < cursor_pos)
1608+ {
1609+ diag
1610+ } else if let Some(diag) = doc.diagnostics().last() {
1611+ diag.range.start
1612+ } else {
1613+ return;
1614+ };
1615+
1616+ goto_pos(editor, diag);
1617+}
1618+
15391619pub fn signature_help(cx: &mut Context) {
15401620 let (view, doc) = cx.current();
15411621
@@ -2433,3 +2513,35 @@ pub fn view_mode(cx: &mut Context) {
24332513 }
24342514 })
24352515}
2516+
2517+pub fn left_bracket_mode(cx: &mut Context) {
2518+ cx.on_next_key(move |cx, event| {
2519+ if let KeyEvent {
2520+ code: KeyCode::Char(ch),
2521+ ..
2522+ } = event
2523+ {
2524+ match ch {
2525+ 'd' => goto_prev_diag(cx),
2526+ 'D' => goto_first_diag(cx),
2527+ _ => (),
2528+ }
2529+ }
2530+ })
2531+}
2532+
2533+pub fn right_bracket_mode(cx: &mut Context) {
2534+ cx.on_next_key(move |cx, event| {
2535+ if let KeyEvent {
2536+ code: KeyCode::Char(ch),
2537+ ..
2538+ } = event
2539+ {
2540+ match ch {
2541+ 'd' => goto_next_diag(cx),
2542+ 'D' => goto_last_diag(cx),
2543+ _ => (),
2544+ }
2545+ }
2546+ })
2547+}