Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
d545759e
Commit
d545759e
authored
Jul 09, 2021
by
Waqar Ahmed
Committed by
Christoph Cullmann
Jul 11, 2021
Browse files
Location history improvements
parent
2a47844a
Pipeline
#69942
canceled with stage
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
kate/kateviewspace.cpp
View file @
d545759e
...
...
@@ -487,35 +487,40 @@ void KateViewSpace::addPositionToHistory(const QUrl &url, KTextEditor::Cursor c,
return
;
}
// we are in the middle of jumps somewhere?
if
(
!
m_locations
.
empty
()
&&
currentLocation
+
1
<
m_locations
.
size
())
{
// erase all forward history
m_locations
.
erase
(
m_locations
.
begin
()
+
currentLocation
+
1
,
m_locations
.
end
());
}
// if same line, remove last entry
if
(
!
m_locations
.
empty
()
&&
m_locations
.
back
().
url
==
url
&&
m_locations
.
back
().
cursor
.
line
()
==
c
.
line
())
{
m_locations
.
pop_back
();
}
// Check if the location is at least "viewLineCount" away
if
(
!
calledExternally
&&
!
m_locations
.
empty
()
&&
m_locations
.
back
().
url
==
url
)
{
int
line
=
c
.
line
();
int
lastLocLine
=
m_locations
.
back
().
cursor
.
line
();
auto
view
=
m_viewManager
->
activeView
();
int
viewLineCount
=
view
->
lastDisplayedLine
()
-
view
->
firstDisplayedLine
();
int
lowerBound
=
lastLocLine
-
viewLineCount
;
int
upperBound
=
lastLocLine
+
viewLineCount
;
if
(
lowerBound
<=
line
&&
line
<=
upperBound
)
{
// If new pos is same as "current pos", replace it with new one
bool
currPosIsInSameLine
=
false
;
if
(
currentLocation
<
m_locations
.
size
())
{
const
auto
&
currentLoc
=
m_locations
.
at
(
currentLocation
);
currPosIsInSameLine
=
currentLoc
.
url
==
url
&&
currentLoc
.
cursor
.
line
()
==
c
.
line
();
}
// Check if the location is at least "viewLineCount" away from the "current" position in m_locations
if
(
!
calledExternally
&&
currentLocation
<
m_locations
.
size
()
&&
m_locations
.
at
(
currentLocation
).
url
==
url
)
{
const
int
currentLine
=
m_locations
.
at
(
currentLocation
).
cursor
.
line
();
const
int
newPosLine
=
c
.
line
();
const
auto
view
=
m_viewManager
->
activeView
();
const
int
viewLineCount
=
view
->
lastDisplayedLine
()
-
view
->
firstDisplayedLine
();
const
int
lowerBound
=
currentLine
-
viewLineCount
;
const
int
upperBound
=
currentLine
+
viewLineCount
;
if
(
lowerBound
<=
newPosLine
&&
newPosLine
<=
upperBound
)
{
if
(
currPosIsInSameLine
)
{
m_locations
[
currentLocation
].
cursor
=
c
;
}
return
;
}
}
// limit size to 50, remove first 10
if
(
m_locations
.
size
()
>=
50
)
{
m_locations
.
erase
(
m_locations
.
begin
(),
m_locations
.
begin
()
+
10
);
if
(
currPosIsInSameLine
)
{
m_locations
[
currentLocation
].
cursor
.
setColumn
(
c
.
column
());
return
;
}
// we are in the middle of jumps somewhere?
if
(
!
m_locations
.
empty
()
&&
currentLocation
+
1
<
m_locations
.
size
())
{
// erase all forward history
m_locations
.
erase
(
m_locations
.
begin
()
+
currentLocation
+
1
,
m_locations
.
end
());
}
/** this is our new forward **/
...
...
@@ -532,6 +537,11 @@ void KateViewSpace::addPositionToHistory(const QUrl &url, KTextEditor::Cursor c,
m_historyBack
->
setEnabled
(
true
);
Q_EMIT
m_viewManager
->
historyBackEnabled
(
true
);
}
// limit size to 50, remove first 10
if
(
m_locations
.
size
()
>=
50
)
{
m_locations
.
erase
(
m_locations
.
begin
(),
m_locations
.
begin
()
+
10
);
}
}
int
KateViewSpace
::
hiddenDocuments
()
const
{
...
...
@@ -738,7 +748,8 @@ void KateViewSpace::restoreConfig(KateViewManager *viewMan, const KConfigBase *c
void
KateViewSpace
::
goBack
()
{
if
(
m_locations
.
empty
()
||
currentLocation
==
0
)
{
if
(
m_locations
.
empty
()
||
currentLocation
<=
0
)
{
currentLocation
=
0
;
return
;
}
...
...
@@ -784,7 +795,9 @@ void KateViewSpace::goForward()
if
(
m_locations
.
empty
())
{
return
;
}
if
(
currentLocation
==
m_locations
.
size
()
-
1
)
{
// We are already at the last position
if
(
currentLocation
>=
m_locations
.
size
()
-
1
)
{
return
;
}
...
...
Waqar Ahmed
@waqar
mentioned in commit
e7241670
·
Jul 17, 2021
mentioned in commit
e7241670
mentioned in commit e7241670e1c270732d827f1513a4d6dd2f3301df
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment