Skip to content

Commit cff3c84

Browse files
Don't erase bookmark style when applying other styles
Add an automatic test for this. Closes eng/ide/gnatstudio#24
1 parent ef932d5 commit cff3c84

File tree

5 files changed

+53
-0
lines changed

5 files changed

+53
-0
lines changed

src_editor/src/src_editor_module.adb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,6 +2879,7 @@ package body Src_Editor_Module is
28792879
Line_Highlighting.Add_Category (Messages_Styles (Low));
28802880
Line_Highlighting.Add_Category (Messages_Styles (Informational));
28812881
Line_Highlighting.Add_Category (Debugger_Current_Line_Style);
2882+
Line_Highlighting.Add_Category (Bookmark_Default_Style);
28822883

28832884
Regenerate_Recent_Files_Menu (Kernel);
28842885
end Register_Module;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
procedure Main is
2+
A : Integer := 1;
3+
B : Integer := 2;
4+
begin
5+
A := A + B;
6+
end Main;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$GPS --traceon=GPS.INTERNAL.Source_Editor.Buffer_Debug --load=python:test.py
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""
2+
This test checks that we correctly highlight the lines when
3+
bookmarks are being set. It also checks that the bookmark
4+
highlighting does not disappear when highlighting a part of
5+
the line.
6+
"""
7+
8+
import GPS
9+
from gs_utils.internal.utils import *
10+
import gs_utils.internal.dialogs as dialogs
11+
12+
13+
EXPECTED_HIGHLIGHTING = ["", "Editor bookmarks", "", "", "", "", ""]
14+
15+
16+
@run_test_driver
17+
def test_driver():
18+
# Create a bookmark in main.adb and check that the line
19+
# is correctly highlighted.
20+
buf = GPS.EditorBuffer.get(GPS.File("main.adb"))
21+
editor_view = buf.current_view()
22+
editor_view.goto(buf.at(2, 4))
23+
GPS.execute_action("bookmark create")
24+
25+
gps_assert(
26+
buf.debug_dump_line_highlighting(),
27+
EXPECTED_HIGHLIGHTING,
28+
"Line highlighting for bookmarks does not work",
29+
)
30+
31+
# Search for 'Integer': this should highlight the search result
32+
# on the same line as the bookmark. Verify that the bookmark highlighting
33+
# is still present though.
34+
s = dialogs.Search()
35+
yield s.open_and_yield()
36+
yield wait_idle()
37+
s.pattern.set_text("Integer")
38+
yield s.yield_find_all()
39+
40+
gps_assert(
41+
buf.debug_dump_line_highlighting(),
42+
EXPECTED_HIGHLIGHTING,
43+
"Line highlighting for bookmarks has been removed after searching",
44+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: 'gs.123.bookmarks.highlighting'

0 commit comments

Comments
 (0)