Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
552de890
Commit
552de890
authored
6 years ago
by
Dmitry.Krasilschikov
Browse files
Options
Download
Email Patches
Plain Diff
IDEA-200666 respect column number for breadcrumbs
parent
7e9caeef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
platform/platform-impl/src/com/intellij/ide/actions/RecentLocationManager.java
+24
-16
...l/src/com/intellij/ide/actions/RecentLocationManager.java
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorState.java
+8
-0
...ntellij/openapi/fileEditor/impl/text/TextEditorState.java
with
32 additions
and
16 deletions
+32
-16
platform/platform-impl/src/com/intellij/ide/actions/RecentLocationManager.java
+
24
-
16
View file @
552de890
...
...
@@ -5,6 +5,7 @@ import com.intellij.codeInsight.breadcrumbs.FileBreadcrumbsCollector;
import
com.intellij.openapi.components.ProjectComponent
;
import
com.intellij.openapi.editor.Document
;
import
com.intellij.openapi.editor.Editor
;
import
com.intellij.openapi.editor.LogicalPosition
;
import
com.intellij.openapi.editor.RangeMarker
;
import
com.intellij.openapi.editor.colors.EditorColorsScheme
;
import
com.intellij.openapi.editor.impl.EditorComponentImpl
;
...
...
@@ -67,7 +68,7 @@ public class RecentLocationManager implements ProjectComponent {
@NotNull
Collection
<
Iterable
<?
extends
Crumb
>>
getBreadcrumbs
(
@NotNull
PlaceInfo
placeInfo
,
boolean
showChanged
)
{
PlaceInfoPersistentItem
item
=
getMap
(
showChanged
).
get
(
placeInfo
);
return
item
==
null
?
ContainerUtil
.
emptyList
()
:
item
.
get
Result
();
return
item
==
null
?
ContainerUtil
.
emptyList
()
:
item
.
get
Crumbs
();
}
@Nullable
...
...
@@ -140,14 +141,13 @@ public class RecentLocationManager implements ProjectComponent {
return
;
}
int
line
=
getLineNumber
(
changePlace
);
if
(
l
ine
==
-
1
)
{
LogicalPosition
logicalPosition
=
getLogicalPosition
(
changePlace
);
if
(
l
ogicalPosition
==
null
)
{
return
;
}
Document
document
=
editor
.
getDocument
();
TextRange
range
=
getLinesRange
(
document
,
line
);
TextRange
range
=
getLinesRange
(
document
,
logicalPosition
.
line
);
String
text
=
document
.
getText
(
TextRange
.
create
(
range
.
getStartOffset
(),
range
.
getEndOffset
()));
int
newLinesBefore
=
StringUtil
.
countNewLines
(
...
...
@@ -164,20 +164,25 @@ public class RecentLocationManager implements ProjectComponent {
int
startOffset
=
document
.
getLineStartOffset
(
firstLineAdjusted
);
int
endOffset
=
document
.
getLineEndOffset
(
lastLineAdjusted
);
items
.
put
(
changePlace
,
new
PlaceInfoPersistentItem
(
getBreadcrumbs
(
project
,
editor
,
changePlace
,
l
ine
),
items
.
put
(
changePlace
,
new
PlaceInfoPersistentItem
(
getBreadcrumbs
(
project
,
editor
,
changePlace
,
l
ogicalPosition
),
document
.
createRangeMarker
(
startOffset
,
endOffset
),
editor
.
getColorsScheme
()));
}
private
static
int
getLineNumber
(
@NotNull
PlaceInfo
changePlace
)
{
@Nullable
private
static
LogicalPosition
getLogicalPosition
(
@NotNull
PlaceInfo
changePlace
)
{
FileEditorState
navigationState
=
changePlace
.
getNavigationState
();
if
(!(
navigationState
instanceof
TextEditorState
))
{
return
-
1
;
return
null
;
}
Collection
<
Integer
>
lines
=
((
TextEditorState
)
navigationState
).
getCaretLines
();
Integer
line
=
ContainerUtil
.
getFirstItem
(
lines
);
return
line
==
null
?
-
1
:
line
;
Collection
<
Integer
>
caretColumns
=
((
TextEditorState
)
navigationState
).
getCaretColumns
();
Integer
column
=
ContainerUtil
.
getFirstItem
(
caretColumns
);
return
line
!=
null
&&
column
!=
null
?
new
LogicalPosition
(
line
,
column
)
:
null
;
}
@Nullable
...
...
@@ -209,13 +214,16 @@ public class RecentLocationManager implements ProjectComponent {
private
static
Collection
<
Iterable
<?
extends
Crumb
>>
getBreadcrumbs
(
@NotNull
Project
project
,
@NotNull
Editor
editor
,
@NotNull
PlaceInfo
changePlace
,
int
line
)
{
@NotNull
LogicalPosition
logicalPosition
)
{
FileBreadcrumbsCollector
collector
=
FileBreadcrumbsCollector
.
findBreadcrumbsCollector
(
project
,
changePlace
.
getFile
());
Collection
<
Iterable
<?
extends
Crumb
>>
result
=
ContainerUtil
.
emptyList
();
if
(
collector
!=
null
)
{
CollectConsumer
<
Iterable
<?
extends
Crumb
>>
consumer
=
new
CollectConsumer
<>();
int
lineStartOffset
=
editor
.
getDocument
().
getLineStartOffset
(
line
);
collector
.
updateCrumbs
(
changePlace
.
getFile
(),
editor
,
lineStartOffset
,
new
ProgressIndicatorBase
(),
consumer
);
collector
.
updateCrumbs
(
changePlace
.
getFile
(),
editor
,
editor
.
logicalPositionToOffset
(
logicalPosition
),
new
ProgressIndicatorBase
(),
consumer
);
result
=
consumer
.
getResult
();
}
return
result
;
...
...
@@ -259,14 +267,14 @@ public class RecentLocationManager implements ProjectComponent {
}
private
static
class
PlaceInfoPersistentItem
{
private
final
Collection
<
Iterable
<?
extends
Crumb
>>
my
Result
;
@NotNull
private
final
Collection
<
Iterable
<?
extends
Crumb
>>
my
Crumbs
;
@NotNull
private
final
RangeMarker
myRangeMarker
;
@NotNull
private
final
EditorColorsScheme
myScheme
;
PlaceInfoPersistentItem
(
@NotNull
Collection
<
Iterable
<?
extends
Crumb
>>
crumbs
,
@NotNull
RangeMarker
rangeMarker
,
@NotNull
EditorColorsScheme
scheme
)
{
my
Result
=
crumbs
;
my
Crumbs
=
crumbs
;
myRangeMarker
=
rangeMarker
;
myScheme
=
scheme
;
}
...
...
@@ -277,8 +285,8 @@ public class RecentLocationManager implements ProjectComponent {
}
@NotNull
private
Collection
<
Iterable
<?
extends
Crumb
>>
get
Result
()
{
return
my
Result
;
private
Collection
<
Iterable
<?
extends
Crumb
>>
get
Crumbs
()
{
return
my
Crumbs
;
}
@NotNull
...
...
This diff is collapsed.
Click to expand it.
platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/text/TextEditorState.java
+
8
-
0
View file @
552de890
...
...
@@ -5,6 +5,7 @@ import com.intellij.openapi.editor.Document;
import
com.intellij.openapi.fileEditor.FileEditorState
;
import
com.intellij.openapi.fileEditor.FileEditorStateLevel
;
import
com.intellij.util.containers.ContainerUtil
;
import
org.jetbrains.annotations.Contract
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
...
...
@@ -100,10 +101,17 @@ public final class TextEditorState implements FileEditorState {
}
@NotNull
@Contract
(
pure
=
true
)
public
Collection
<
Integer
>
getCaretLines
()
{
return
ContainerUtil
.
map
(
CARETS
,
caret
->
caret
.
LINE
);
}
@NotNull
@Contract
(
pure
=
true
)
public
Collection
<
Integer
>
getCaretColumns
()
{
return
ContainerUtil
.
map
(
CARETS
,
caret
->
caret
.
COLUMN
);
}
@Override
public
boolean
canBeMergedWith
(
FileEditorState
otherState
,
FileEditorStateLevel
level
)
{
if
(!(
otherState
instanceof
TextEditorState
))
return
false
;
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help